#include<iostream>
#include<cstring>
using namespace std;
class person{
protected:
int Num;
char Name[20];
public:
void Register(int num,char *name)
{
Num=num;
strcpy(Name,name);
}
virtual void showme()
{
cout<<"编号:"<<Num<<endl;
cout<<"姓名:"<<Name<<endl;
}
};
class teacher:public person
{
char Title[20];
char Department[20];
public:
teacher(int num,char*name,char*dept,char*department);
virtual void showme()
{
person::showme();
cout<<"职位:"<<Title<<endl;
cout<<"部门:"<<Department<<endl;
}
};
teacher::teacher(int num,char *name,char *title,char *department)
{
Register(num,name);
strcpy(Title,title);
strcpy(Department,department);
}
class student:public person
{
int Score;
char Class[20];
public:
student(int num,char *name,int score,char *classid);
virtual void showme()
{
person::showme();
cout<<"成绩:"<<Score<<endl;
cout<<"班级:"<<Class<<endl;
}
};
student::student(int num,char *name,int score,char *classid)
{
Register(num,name);
Score=score;
strcpy(Class,classid);
}
int main()
{
char name1[20];
char name2[20];
int num;
char classid[20];
int score;
cout<<"请输入学生的编号,姓名,班级,成绩:";
cin>>num>>name1>>score>>classid;
student s1(num,name1,score,classid);
student *ps=&s1;
ps->showme();
char title[20],department[20];
cout<<"请输入老师的编号,姓名,职称,部门:";
cin>>num;
cin>>name2;
cin>>title;
cin>>department;
teacher t1(num,name2,title,department);
teacher *pt=&t1;
pt->showme();
return 0;
}