#include?<iostream>
#include?<string>
using?namespace?std;
/**
?*?定義類:Student
?*?數據成員:m_strName
?*?無參構造函數:Student()
?*?有參構造函數:Student(string?_name)
?*?拷貝構造函數:Student(const?Student&?stu)
?*?析構函數:~Student()
?*?數據成員函數:setName(string?_name)、getName()
?*/
class?Student
{
????public:
????Student()
????{
????????m_strName="";
????}
????Student(string?_name)
????{
????????m_strName=_name;
????}
????Student(const?Student&?stu){};
????//~Student();
????
????void?setName(string);
????string?getName();
????private:
????string?m_strName;
};void?Student::setName(string?_name){????m_strName=_name;}string?Student::getName(){????return?m_strName;}int?main(void){????Student?stu("慕課網");?cout<<stu.getName()<<endl;?return?0;}
2018-11-26
因為你的析構函數沒有函數體?? 應該是? ~student(){};
2018-12-14
啥時候,析構函數花括號后面還要加分號的?~Student(){}