I want to use a class method in the signal method
signal(SIGALRM, syncro);
syncro is the name of another class method.
void states::syncro( int parameter )
{
}
I try with syncro, &syncro, states::syncro, and &states::syncro but all of them throw error messages when compiling.
error: argument of type ‘void (states::)(int)’ does not match ‘void (*)(int)’
You are able to call only free function or static class function in this case
signal‘s signature isThat means that it accepts only pointer to free function or static function.
Note, that you should always have an object to call member function, say, if you have
you can only call
obj.method(), but neverS::method()ormethod(), and pointer toS::methodhas typevoid (S::*)().But if your
S::method()was declared static you could call it withS::method().That’s why pointers to free functions are incompatible with pointers to member functions.