There is such code:
void foo(void (*fun_ptr)()){
}
class B{
public:
B(){
foo(some_fun);
}
void some_fun(){}
};
Compilation error:
error: argument of type ‘void (B::)()’ does not match ‘void (*)()’
How to point to member function in this case? I cannot change declaration of function foo, only class B!
Declare B::some_fun() as static as there is an implicit this pointer passed as an argument to member functions. Note that making B::some_fun() static prevents access to non-public non-static members of B.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With