我有2节课
class B {
public:
int func(int i);
};
class A {
public:
typedef int (B::*fPtr)(int);
void run();
B* mB;
};
void A::run() {
// create a pointer
fPtr p = &(B::func);
// invoke the function
mB->*p(2); <------- Compilation Error
}
Run Code Online (Sandbox Code Playgroud)
我需要的是在A的运行函数中创建一个指向func()的指针.我得到一个编译错误,说mB不对应于带有1个参数的函数.
请帮忙