类的静态成员函数如何调用成员变量??(大侠请指教)
class Test
{
public:
.........
static void print();
private:
int x,y;
};
.........
void Test::print()
{
cout<<"x:"<<x<<endl //illegal reference to data member 'Test::x' in a static member function
<<"y:"<<y<<endl;
}
.........
void main()
{
Test a;
Test::print();
}
编译时出错
error:illegal reference to data member 'Test::x' in a static member function
静态成员函数不能调用成员变量吗?
如果能,应该如何写呢?
请大侠指教........................
谢谢~~~~~~