为什么以下代码会导致错误:
class A {
public:
typedef void (A::*funptr)(void);
void fun(void ) {
cout << " Fun Call " <<endl;
}
void foo(void ) {
cout << " Foo Call " <<endl;
}
funptr p[2];
funptr q;
A()
{
p[0]=&A::foo;
p[1]=&A::fun;
q =&A::fun;
}
};
int main ()
{
A obj;
(obj.*q)(void);
//(obj.p[0])();
//(obj.p[1])();
return 0;
}