Problem Description
一个教学系统至少有学生和教师两种类型的人员,假设教师的数据有教师编号、姓名、年龄、性别、职称和系别,
学生的数据有学号、姓名、年龄、性别、班级和语文、数学、英语三门课程的成绩。
现编程完成学生和教师档案数据的输入和显示。
要求如下:
设计三个类Person、Teacher、Student,Person是Teacher和Student的基类,
具有此二类共有的数据成员编号、姓名、年龄、性别,并具有输入和显示这些数据的成员函数;
Teacher类继承了Person类的功能,并增加职称和系别等数据成员和进行输入和显示的成员函数。
Student类继承了Person类的功能,并增加班级和语文、数学、英语三门课程的成绩等数据成员
及进行输入和显示的成员函数。
//你的代码将被嵌入在这里
int main() {
Teacher t1, t2(“T002”, “张华”, 33, “男”, “讲师”, “计算机系”);
Student s1, s2(“S002”, “李丽”, 19, “女”, “0309202”, 90, 92, 98);
t1.inputTeacher();
s1.inputStudent();
t1.printTeacher();
t2.printTeacher();
s1.printStudent();
s2.printStudent();
Person p = t1;
p.printPerson();
return 0;
}
Sample Input
T001 陈军 40 女 教授 电气工程
S001 向辉 28 男 0309201 99 98 97
Sample Output
num:T001
name:陈军
age:40
sex:女
title:教授
dep:电气工程
num:T002
name:张华
age:33
sex:男
title:讲师
dep:计算机系
num:S001
name:向辉
age:28
sex:男
classes:0309201
chinese:99
math:98
english:97
num:S002
name:李丽
age:19
sex:女
classes:0309202
chinese:90
math:92
english:98
num:T001
name:陈军
age:40
sex:女
#include<iostream>
#include<string.h>
#include<string>
#include<iomanip>
#include<math.h>
using namespace std;
class Person
{
public:
string bh, name,sex;
int age;
Person(string a = "", string b = "", int c = 0, string d = "")
{
bh = a; name = b; age = c; sex = d;
}
void printPerson()
{
cout << "num:" << bh << endl;
cout << "name:" << name << endl;
cout << "age:" << age << endl;
cout << "sex:" << sex << endl;
}
};
class Teacher:public Person
{
public:
string zc, xb;
Teacher(string a = "", string b = "",