Original Post
Say if I have
class Test
{
public:
void (*FunctionPointer)(void);
}
Then I can get FunctionPointer to point to and call a generic C style function like so:
void Function( void )
{
// process
}
void main()
{
Test t;
t.FunctionPointer = &Function
t.FunctionPointer();
}
But sending a class method in the same manner doesnt seem to work, like this:
class AnotherClass
{
public:
void Function( void );
}
void main()
{
Test t;
AnotherClass ac;
t.FunctionPointer = &(ac.Function);
}
Carrying on like this to call the function pointer results in C2440 error in VC++ (function pointer wont evaluate). Why doesnt it work? Logically it looks similar enough to the C version.