4.26

发布时间 2023-04-26 20:49:59作者: 张佳木

#include<iostream>

using namespace std;

#include<string>

class student {

public:

    student(void);

    ~student(void);

    void setValues(int n, string str, char c);

    void display();

protected:

    int num;

    string name;

    char sex;

};

student::student(void){}

student::~student(void){}

void student::setValues(int n, string str, char c) {

    num = n;

    name = str;

    sex = c;

}

void student::display() {

    cout << num << "" << name << "" << sex << endl;

}

class postgraduent : public student {

public:

    postgraduent(void);

    ~postgraduent(void);

    void setAdvisor(string str) {

         advisor = str;

    }

    string getAdvisor() {

         return advisor;

    }

private:

    string advisor;

};

postgraduent::postgraduent(void) {

 

}

postgraduent::~postgraduent(void) {

 

}