In C++, I have many functions (one, two three...) that look like this:
int MyClass::one(Mynamespace::Data* data)
{
//do something
return 0;
}
I also have an action function that I want to use to call one, two, three... functions with a function pointer.
int MyClass::action(Mynamespace::Data* data)
{
int (*actionFunction)(Mynamespace::Data*);
actionFunction = data->name; // the name is a string with the function name (one, two, three...)
return (*actionFunction)(data);
}
The error I get says:
int (MyClass::)(Mynamespace::Data*)’ does not match ‘int (*)(Mynamespace::Data*)
What am I doing wrong? If there is another way to do this fast and easy I would like to learn it too. Thank you
nameactually is, if you have declared the member yourself (and if you have declared it yourself, then you should be able to figure out howactionFunctionshould be declared). So could you let us know how exactly have you declaredname?