Class 中定义的成员,只能通过其对象来调用
A.h:
class A
{
public:
A();
~A();
public:
private:
public:
//A *a;//方案一 Error
string AString;
}
A.cpp:
A::A()
{
AString="helloword!!";//error
a->AString="helloword!!";//suceed
}
int main()
{
//a=new A();//方案一 Error
A *a=new A();//方案二
a->AString="helloword!!";//suceed
AString="helloword!!";//error
}