Reputation: 105
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);
};
Upvotes: 9
Views: 5318
Reputation: 59811
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++.
Upvotes: 11