在復習初始化參數列表的時候,把數據成員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;
}