I'm trying to call a function pointer that points to a member function and I either get the error
Error 3 error C2064: term does not evaluate to a function taking 0 arguments
or
Error 3 error C2171: '*' : illegal on operands of type 'Foo::func_t
my code looks like
class Foo
{
void stuff();
void more_stuff();
void my_func();
typedef void(Foo::* func_t)(void);
func_t fptr;
};
void Foo::my_func()
{
//do some stuff
}
void Foo::stuff()
{
fptr = &Foo::my_func;
}
void Foo::more_stuff()
{
if(fptr != 0)
{
(*fptr)(); //error C2171: '*' : illegal on operands of type 'Foo::func_t
(fptr)(); //term does not evaluate to a function taking 0 arguments
}
}
Can anyone see the issue here?