I want to have a class that has a function pointer as a member
here's the function pointer:
typedef double (*Function)(double);
here is a function that matches the definition of a function pointer:
double f1(double x) { return 0; }
here is the class definition:
class IntegrFunction { public: Function* function; };
and somewhere in the main function I want to do something like this:
IntegrFunction func1; func1.function = f1;
But this code does not work.
Can a class member be assigned a function pointer to a global function declared as described above? Or do I need to change something in the definition of a function pointer?
Thanks,
source share