void Student::setName(string _name)
{
m_strName= _name;
}
string Student::getName()
{
return m_strName;
}
int main(void)
{
// 通过new方式实例化对象*stu
Student *stu = new Student();
// 更改对象的数据成员为“慕课网”
stu->setName("慕课网");
// 打印对象的数据成员
cout<<stu->getName()<<endl;
return 0;
}
第三部分!
{
m_strName= _name;
}
string Student::getName()
{
return m_strName;
}
int main(void)
{
// 通过new方式实例化对象*stu
Student *stu = new Student();
// 更改对象的数据成员为“慕课网”
stu->setName("慕课网");
// 打印对象的数据成员
cout<<stu->getName()<<endl;
return 0;
}
第三部分!
Student::Student()
{
m_strName="Jim";
}
Student::Student(string _name)
{
m_strName= _name;
}
Student::Student(const Student& stu)
{
cout<<"Student(const Student& stu)"<<endl;
}
Student::~Student()
{
cout<<"~Student()"<<endl;
}
第二部分
{
m_strName="Jim";
}
Student::Student(string _name)
{
m_strName= _name;
}
Student::Student(const Student& stu)
{
cout<<"Student(const Student& stu)"<<endl;
}
Student::~Student()
{
cout<<"~Student()"<<endl;
}
第二部分