#include <iostream>
using namespace std;
class Student
{
protected:
string name;
int age;
int score;
public:
Student(){}
Student(string name, int age, int score)
{
this->name = name;
this->age = age;
this->score = score;
}
void show()
{
cout<<"student message>>>"<<this->name<<'\t'<<this->age<<'\t'<<this->score<<endl;
}
};
class Teacher
{
protected:
int age;
string job;
public:
Teacher(){}
Teacher(int age, string job)
{
this->age = age;
this->job = job;
}
void show()
{
cout<<"teacher message>>>"<<this->age<<'\t'<<this->job<<endl;
}
};
class Graduate:public Student, public Teacher
{
protected:
string sex;
public:
Graduate(){}
Graduate(string name, int age, int score, int tage, string job, string se):Student(name,age,score),Teacher(tage,job),sex(se){}
void show()
{
cout<<"姓名:"<<this->name<<" 年龄:"<<Student::age<<" 成绩:"<<this->score<<" 性别:"<<this->sex<<" 指导教师年龄:"<<Teacher::age<<" 职称:"<<this->job<<endl;
}
};
int main()
{
Graduate gra("张三",22,98,45,"教授","男");
gra.show();
return 0;
}
结果:
姓名:张三 年龄:22 成绩:98 性别:男 指导教师年龄:45 职称:教授