#include <iostream>
#include <string>
using namespace std;
class person{
public :
person(string nu ,string na)
{
num=nu;
name=na;
}
void display()
{
cout<<"姓名:"<<name<<endl<<"编号:" <<num<<endl;
}
protected:
string num;
string name;
};
class teacher :public person {
public:
teacher(string t ,string s,string nu ,string na):person(nu,na)
{
title =t;
section =s;
}
void display()
{
person::display();
cout<<"职称:"<<title<<endl<<"部门: "<<section<<endl;
}
protected:
string title,section;
};
class student :public person{
public:
student(string c,int s,string nu,string na):person(nu,na)
{
code =c;
score =s;
}
void display()
{
person::display();
cout<<"班号:"<<code<<endl<<"成绩: "<<score<<endl;
}
protected:
string code;
int score;
};
int main()
{
int f;
string a,b,c,d,e,g,h;
cout<<"输入老师的 职称 部门 编号 姓名"<<endl;
cin>>a>>b>>c>>d;
cout<<"输入学生的 班号 成绩 编号 姓名" <<endl;
cin>>e>>f>>g>>h;
teacher m(a,b,c,d);
student n(e,f,g,h);
m.display();
n.display();
return 0;
}
、学生老师
最新推荐文章于 2022-11-03 14:35:05 发布