我想设置一个函数指针作为类的成员,它是指向同一类中另一个函数的指针。我这么做的原因很复杂。
在本例中,我希望输出为"1“
class A {
public:
int f();
int (*x)();
}
int A::f() {
return 1;
}
int main() {
A a;
a.x = a.f;
printf("%d\n",a.x())
}
但这在编译时失败了。为什么?
https://stackoverflow.com/questions/2402579
复制相似问题