类中的const常量必须要在拷贝构造函数中定义吗
class Teacher
{
public:
Teacher(string name = "JIM", unsigned int age = 20, unsigned int max = 20);
Teacher(const Teacher &tea);
private:
string m_strName;
string m_strGender;
unsigned int m_iAge;
const unsigned int m_iMax;
};
Teacher::Teacher(string name, unsigned int age, unsigned int max):
m_strName(name),m_iAge(age), m_iMax(max)
{
cout << "Teacher(string name, unsigned int age)" << endl;
}
Teacher::Teacher(const Teacher &tea)
{
cout << "Teacher::Teacher(const Teacher &tea)" << endl;
}
Teacher t1;
Teacher t2 = t1; //编译error