I have problems with pointers to class-member functions.
I'm using Ms VC++ 6.0 Enterprise Ed. (with ServicePack 6)
Under WinXP Pro (if it makes any difference).
The problem is that (apparently) I can declare and initialize a pointer
to a member of a Class. No errors/warnings during compilation.
But when I dereference the pointer to call the function, I get the error
term does not evaluate to a function
I searched through MSDN to no avail. Few articles found, and of no help.
One of them suggested to change my project settings (/vms /vmm...), but I
have tried all combinations and nothing worked.
Another article suggested to not use the 'this' pointer when dereferencing,
but it didn't solve my problem.
I'm not a genius of C++... Please help me.
Roughly this is my situation:
Two classes: A and B.
Class A contains a useful method.
Class B first setup a pointer to Class A method; then automatically calls it
whenever the main program needs to do certain things with Class B.
Also, it's not a small project and everything is wrapped up in a namespace (if it makes any difference).
Here is a code that produces the error:
(namespace is omitted)
typedef void (CFunc::*FP) (void); // FP is a pointer to a function (member of class CFunc) that
// receives no arguments and returns no arguments.
// Yep, same type as 'CFunc::Blah()' prototype.
void Blah (void); // <--- we want to setup a pointer to this function.
void CFunc::Blah (void)
// do something...
FP pfnBlah; // declares a pointer to 'CFunc::Blah()' (see typedef above).
// Whether this pointer is private or public, makes no difference:
// works either way (apparently!).
void SetFuncPtr (FP pFunc)
this->pfnBlah = pFunc; // setup our pointer.
void DoSomething (void)
// Let's use our pointer to call 'CFunc::Blah()'.
// without dereferencing.
this->pfnBlah (); // <--- error C2064 "tern does not evaluate to a function".
// by dereferencing.
*(this->pfnBlah) (); // <--- fails as well... error C2064
// NOTE : I also tried both calls without the 'this' pointer. Didn't work.
void main (void)
// Istantiate our two classes.
// Calls 'CCall::SetFuncPtr()' method to setup a function pointer pointing to 'CFunc::Blah()'.
// So far things work and no error or warning is raised when compiling.
// Now let's make class 'CCall' USE its pointer to 'CFunc::Blah()' method.
Thanks in advance for any help!