#include <stdlib.h>
#include <iostream>
#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_intScore;
}
void initScore() {
m_intScore = 0;
}
void study(int _score) {
m_intScore += _score;
}
private:
string m_strName;
string m_strGender;
int m_intScore;
};
int main() {
Student stu;
stu.initScore();
stu.setGender("女");
stu.setName("张三");
stu.study(5);
stu.study(4);
cout << stu.getName() << " " << stu.getGender()<< " " << stu.getScore() << endl;
system("pause");
return 0;
} |
|