Problem: passing function as argument !!!
Hi, I'm having a problem in pass a function as argument to another function.
This call is made by reference, and the function called is declared into a class.
A example of my problem is:
Code:
class ExClass {
public:
int func(const int &); //***
};
int ExClass::func(const int &z) { return(z); }
template <class T>
void example(T &func) {}
int main(){
ExClass f;
example( f.func );
return(0);
}
When I compile that, I got such error:
In function ‘int main()’:
error: no matching function for call to ‘example(<unresolved overloaded function type>)’
note: candidates are: void example(T&) [with T = int (ExClass::*)(const int&)]
*** It's good to mention that if I declared "func" as "static int func(const int &);" into the "ExClass", I get no error. But I need let "func" be non-static.
What am I supposed to do?
Thank you.