【C++】结构体、重载

#include 
#include    //<==>
#include 
#include 
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;
}

【C++】结构体、重载_第1张图片

你可能感兴趣的:(c++,开发语言)