我的哪兒有錯(cuò)為什么不通過(guò)
class Student
{
public:
??? // 定義數(shù)據(jù)成員封裝函數(shù)setName()
??? void SteName(string_str){
??????? m_strName = _str;
??? }
???
???
??? // 定義數(shù)據(jù)成員封裝函數(shù)getName()
?? void getName()
?? {
??????? return m_strName;
??? }
???
???
//定義Student類私有數(shù)據(jù)成員m_strName
private:
?? string m_strName;
};
int main()
{
??? // 使用new關(guān)鍵字,實(shí)例化對(duì)象
?Student *str = new student();
??? // 設(shè)置對(duì)象的數(shù)據(jù)成員
?str->setName("慕課網(wǎng)");
??? // 使用cout打印對(duì)象str的數(shù)據(jù)成員
??? cout << str->getName() << endl;
??? // 將對(duì)象str的內(nèi)存釋放,并將其置空
?????? delete str;
?????? str = NULL;
str = NULL;
?????? return 0;
?
}
2017-09-03
void 定義是無(wú)返回值的
還有不要忘了加 #include<stdlib.h>
system("pause");
2017-04-25
string getName()
{
????return m_strName;
}