看不懂這錯誤,不知道怎么改~求施計
不知如何是好~
代碼如下:
// ConsoleApplication2.cpp : 此文件包含 "main" 函數。程序執行將在此處開始并結束。
//
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
/****************************************************/
/*? ? ? ? 數據的封裝
定義一個Student類,含有如下信息:
1、姓名:name
2、性別 :gender
3、學分:(只讀)score
4、學習:study */
/***************************************************/
class student
{
private:
string m_strName;
string m_strGender;
int? m_iScore;
public:
void setName(string _name)
{
m_strName = _name;
}
string getName()
{
return m_strName;
}
void setGender(string _gender)
{
m_strGender = _gender;
}
string getGender()
{
return m_strGender;
}
int getScore()
{
return m_iScore;
}
void initScore()
{
m_iScore = 0;
}
void study(int _score)?
{
m_iScore += _score;
}
};
int main(void)
{
student stu;
stu.initScore();
stu.setName("小志");
stu.setGender("女");
stu.study(10);
stu.study(10);
cout << stu.getName() << "\t性別:" << stu.getGender() << "\t學分:" << stu.getScore() << endl;
system("pause");
return 0;
}
?
2020-02-06