I have a static pointer to function like the following in my class, but I'm not sure how to instantiate it:
class Foo{
private:
static double (*my_ptr_fun)(double,double);
};
The same way you would initialize every other static member object in C++03:
class Foo{
private:
static double (*my_ptr_fun)(double,double);
};
double bar(double, double);
double (*Foo::my_ptr_fun)(double,double) = &bar;
Whatever you would need a static function pointer for anyway.
This is called initialization
. instantiation
means something different in C++.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.