Original Post
Hello, I want to ask about pointers to functions in C++. When I want to use a function pointer in C I use a simple typedef like the following:
typedef int (*pFunc)(void *);
and then I give as an argument the name of a proper function in another one. My problem is that if the function whose pointer I want to give is an object''s method then the compiler starts complaining. eg.
void foo(int x, pFunc func);
class cClass
{
int myFunc(void *x);
};
int main()
{
cClass myClass;
int x=0;
foo(x, myClass.myFunc); //compiler complaints
return 0;
}
--------------------------------------------------------------------------------
How can I overcome this problem? I ''ve tried to typecast the method eg foo(x, (pFunc)myClass.myFunc); but this as you might know doesn''t work
. Can you help me with this?
Thanks, Themis