I have a class which has a data memeber which store a member function pointer. The pointer points to different member functions in different time. I would like to call this funcion pointer from another member function. How can i do this?
class A {
void (A::*fnPointer)() = nullptr;
void callerMemberFunction(){
fnPointer = &A::someMemberFunction; // Store the function
(*fnPointer)(); // I would like to call the function. How can i do?
}
void someMemberFunction(){ ... }
}
You need to specify which object to call the function on:
(this->*fnPointer)();