一般是把 “ 方法”全部放在publice中
属性放在private中
目的:防止类的外部随便修改 属性
只有保证一定的条件才运行你修改属性
为了封装性
class student :
{
public:
bool set (int a);
bool set (string a);
bool read() const;
student();
student(int a, int b);
private:
int age;
string name;
}
110

被折叠的 条评论
为什么被折叠?



