Code:
class CommandInterface {
public:
void createBank(int a) {};
};
int main()
{
CommandInterface a;
typedef void(CommandInterface::*fptr)(int a);
fptr funcPtr = &CommandInterface::createBank;
a.*funcPtr("a");
return 0;
}
I can’t compile the code, because I get one of the 2 following errors:
1.error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘funcPtr (...)’, e.g. ‘(... ->* funcPtr) (...)
or
Called object type 'fptr' (aka '...') is not a function or function pointer
How can I fix this issue?