Possible Duplicate:
How to best pass methods into methods of the same class
I've never had problems passing a function pointer as parameter. This works:
void functionThatTakesFPTR(void(*function)(int), int someValue){
function(someValue);
}
void printValue(int value){
std::printf("%d",value);
}
int main(int argc, char** argv){
functionThatTakesFPTR(&printValue, 8);
return EXIT_SUCCESS;
}
However, passing object function doesn't
void MyClass::setter(float value){ }
void MyClass::testFunction(void(*setterPtr)(float)){ }
void MyClass::someFunc(){
testFunction(&(this->setter));
}
To me this looks like passing the address of this instead of the function, and I'm a bit confused. Is it possible to do so? And is it possible to pass the function pointer of object of another class (of instance MyClass2) ?
Edit: Error I'm getting is "class 'MyClass' has no member 'setter' ".