在复习初始化参数列表的时候,把数据成员max设置const修饰,不仅不能再构造函数内部进行修改,即使设置一个setter函数也不能进行修改了
2020-12-19
#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
string m_strName;
int m_iAge;
};
int main()
{
Student stu;
stu.m_strName = "慕课网";
stu.m_iAge = 2;
cout <<stu.m_strName << " " <<stu.m_iAge<< endl;
return 0;
}
#include <string>
using namespace std;
class Student
{
public:
string m_strName;
int m_iAge;
};
int main()
{
Student stu;
stu.m_strName = "慕课网";
stu.m_iAge = 2;
cout <<stu.m_strName << " " <<stu.m_iAge<< endl;
return 0;
}