最赞回答 / 慕前端7124754
拷贝构造函数那块是不是要用初始化列表Teacher::Teacher(const Teacher& tea):m_strName(_name),m_iAge(_age),m_iNumber(m){}
2016-12-28
class Student
{
public:
// 定义数据成员封装函数setName()
void setName(string _name)
{
m_strName=_name;
}
// 定义数据成员封装函数getName()
string getName(void)
{
return m_strName;
}
//定义Student类私有数据成员m_strName
private:
string m_strName;
};
{
public:
// 定义数据成员封装函数setName()
void setName(string _name)
{
m_strName=_name;
}
// 定义数据成员封装函数getName()
string getName(void)
{
return m_strName;
}
//定义Student类私有数据成员m_strName
private:
string m_strName;
};
Student() {
cout << "Student()" << endl;
}
explicit Student(string name) {
m_strName = name;
cout << "Student(string name)" << endl;
}
Student(const Student& stu) {
cout << "Student(const Student& stu)" << endl;
}
cout << "Student()" << endl;
}
explicit Student(string name) {
m_strName = name;
cout << "Student(string name)" << endl;
}
Student(const Student& stu) {
cout << "Student(const Student& stu)" << endl;
}