What is the difference between a pointer to a function and a pointer to a class member function?
int f (char A, float b);
If it is a normal function, then its type is int (*) (char, float);
If it is a non-static member function, its type is int (ClassName::*) (char, float);
If it is a static member function, its type is the same as a normal function.
How to pass member functions of a class to event handler, thread start function, etc.?
The member function of a class must be combined with an instance of a class to make sense. You can write a function to wrap the class's member functions.
class X { public: void f (); Static void SF ();}; x x*; void wapper_f () {x->F ();} int Main () { // OK / OK}
How do I make it easier to create a type that executes a class member variable?
With a typedef.
class Fred { public: int f (char x); int g (charint (Fred::* fredfn) (char x); void f () { = &fred::f;} void F2 (FREDFN fn) {...} FREDFN f3 () {...}
How to make it easier to call a class member function that is pointed to by a pointer?
#define Call_member_fn (object, Prttomember) ((object). * (prttomember))void Usercode (Fred &Fred, Fredfn FN) { int ans = call_member_fn (Fred, FN) (3);}
Original reference: Https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
C + +: pointers to class member functions