过不去,不知哪错了,封装的代码
代码打了一遍,过不去,不知道哪错了。
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
class Student
{
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;
}
private:
string m_strName;
string m_strGender;
int m_iScore;
};
int main(void)
{
Student stu;
stu.initScore();
stu.setName("zhangsan");
stu.setGender("女");
stu.study(5);
stu.study(3);
cout<<stu.getName()<<" "<<stu.getGender()<<" "<<stu.getScore()<<endl;
system("pause");
return 0;
}