c++中->怎么用?

2024-10-30 17:25:46
推荐回答(1个)
回答1:

class student
{
public:
int age;
};

第一种形式:
student stu;
stu.age=10;

第二种形式:
student* pstu = new student;

pstu->age=10;
delete pstu;