Using a member function pointer within a class

Posted by neuviemeporte on Stack Overflow See other posts from Stack Overflow or by neuviemeporte
Published on 2010-05-24T16:02:58Z Indexed on 2010/05/24 16:51 UTC
Read the original article Hit count: 370

Filed under:
|

Given an example class:

class Fred
{
public:
Fred() 
{
    func = &Fred::fa;
}

void run()
{
     int foo, bar;
     *func(foo,bar);
}

double fa(int x, int y);
double fb(int x, int y);

private:
double (Fred::*func)(int x, int y);
};

I get a compiler error at the line calling the member function through the pointer "*func(foo,bar)", saying: "term does not evaluate to a function taking 2 arguments". What am I doing wrong?

© Stack Overflow or respective owner

Related posts about c++

Related posts about pointer-to-member