cpp
复制代码
#include <iostream>
#include <cstring> //<==><string.h>
#include <cstdio>
#include <string>
using namespace std;
class stu
{
private:
int age;
string sex;
string name;
public:
double grade;
void set(int a,string s,string n);
int getAge();
string getSex();
string getName();
};
int stu::getAge()
{
return age;
}
string stu::getName()
{
return name;
}
string stu::getSex()
{
return sex;
}
void stu::set(int a,string s,string n)
{
age = a;
sex = s;
name = n;
}
int main()
{
stu jack;
jack.set(22,"na","jack");
cout << jack.getAge() << endl;
cout << jack.getName() << endl;
return 0;
}