Не работает такая программа:
#include <iostream>
using namespace std;
class A;
typedef void (A::*func)(void);
class A{
public:
func p;
void a(void){cout<<"a"<<endl;}
void b(void){cout<<"b"<<endl;}
};
int main(void){
A a;
a.p=&A::b;
(a.*p)();
return 0;
}
При компиляции компилятор ругается на строчку (a.*p)();:
test19.cpp: In function `int main()':
test19.cpp:25: error: `p' undeclared (first use this function)
test19.cpp:25: error: (Each undeclared identifier is reported only once for each function it appears in.)
Проверял на g++ 3.3.2 и 3.4.2.
В чем дело?
Заранее благодарен.