知道怎么用就行啦,不需要深入理解对象(对象就是girlFriend)
两种访问方式:
对象.成员
对象指针->成员
看操作,很简单:
#include<iostream>
#include<string>
using namespace std;
class MM
{
public:
string name;
int age;
};
int main()
{
MM girlFriend;
girlFriend.name = "刘亦菲";
MM* p = &girlFriend;
p->age = 18;
cout << "名字:" << p->name
<< "\t芳龄:" << p->age;
return 0;
}