Divick wrote:
To call a member function through a member function pointer does
require an instance of the class whose member function is being called
(the "this" object).
You don't need a class instance if the method is static. It could be
JON might be having a pointer to a static function altogether.
A member function pointer cannot point to a static member function. It
can point only to a non-static member function.
A function pointer, on the other hand, can point to a static member
function (as well as to a global function).
Perhaps some C++ source code will clarify how member function pointers
can be used:
class A
{
public:
static int sf() { return 5;}
int mf() { return -11; }
};
int main()
{
int (*funcPtr)(); // function pointer
int (A::*memFPtr)(); // member function pointer for A
funcPtr = &A::sf; // OK
memFPtr = &A::mf; // OK
funcPtr = &A::mf; // Error - A::mf is not static
memFPtr = &A::sf; // Error - A::sf is static
A a;
(*funcPtr)(); // OK calls A::sf
(a.*memFPtr)(); // OK calls a->sf();
(a.*funcPtr)(); // Error - requires a member function pointer
(*memFPtr)(); // Error - requires class A object
}