#include<iostream>
#include<string.h>
using namespace std;
class Person {
public:
Person(int age ,char name, char sex)
{
this->name[9] = name;
this->sex[5] = sex;
this->age = age;
}
void getP() { cin >> age >> name >> sex ; }
void showP() {
cout <<"名字:"<< name << endl << "年龄:" << age << endl << "性别:" << sex<< endl;
}
~Person(){}
char name[10];
char sex[6];
int age;
};
class Teacher : public Person
{
public:
Teacher(int age, char name, char sex,char position, char course):Person(age,name,sex)
{
this->position[19] = position;
this->course[19] = course;
}
void getT() { cin >> age >> name >> sex>>position>>course; }
void showT(){
cout << "名字:" << name << endl << "年龄:" << age << endl << "性别:" << sex << endl <<"职称:"<< position <<endl<<"课程:"<< course << endl;
}
~Teacher() {}
char position[20];
char course[20];
};
class Student :public Person
{
public:
Student(int age, char name, char sex,char major, char category) :Person(age, name, sex)
{
this->major[19] = major;
this->category[19] = category;
}
void getS() { cin >> age >> name >> sex>>major>>category; }
void showS() {
cout << "名字:" << name << endl << "年龄:" << age << endl << "性别:" << sex << endl <<"专业:"<< major <<endl<<"类型:"<< category << endl;
}
~Student(){}
char major[20];
char category[20];
};
class PostDoctor :public Teacher, public Student
{
};
int main()
{
Person A(33,'李修', '男');
A.getP();
A.showP();
cout<<" "<< endl;
Teacher B( 30,'杨明','男','教授','数学');
B.getT();
B.showT();
cout << " " << endl;
Student C(19,'唐韵', '男','数学','博士');
C.getS();
C.showS();
return 0;
去除get部分输出为中文乱码