Using a member function pointer within a class

前端 未结 5 675
有刺的猬
有刺的猬 2020-12-28 21:21

Given an example class:

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

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

double fa(int x,          


        
5条回答
  •  遥遥无期
    2020-12-28 22:09

    A member function with two args is really a three arg function. 'this' is an implicit argument so the error you are getting is about missing the 'this' arg.

提交回复
热议问题