创建一个教师实例,姓名为Zheng Li,编号为1001,性别为Female,1978年1月1日生,身份证号为1234567890,职务为professor,部门为CST。 创建一个助教实例,姓名为Li Chao,编号为011401,性别为Male,1988年6月1日生,身份证号为12345619880601,职务为TA,部门为CST,班号为cst61,专业为computer science,导师为Zheng Li。 依次输出该助教的姓名,编号,部门,班号,专业和导师。根据提示,在右侧编辑器补充代码,并输出正确的值。
时间: 2024-04-27 20:25:33 浏览: 94
```c++
#include <iostream>
#include <string>
using namespace std;
class Teacher {
public:
string name;
int id;
string gender;
string birthdate;
string idcard;
string position;
string department;
Teacher(string n, int i, string g, string b, string ic, string p, string d) {
name = n;
id = i;
gender = g;
birthdate = b;
idcard = ic;
position = p;
department = d;
}
};
class Assistant : public Teacher {
public:
string class_num;
string major;
Teacher *advisor;
Assistant(string n, int i, string g, string b, string ic, string p, string d, string cn, string m, Teacher *a) : Teacher(n, i, g, b, ic, p, d) {
class_num = cn;
major = m;
advisor = a;
}
};
int main() {
Teacher t("Zheng Li", 1001, "Female", "1978-01-01", "1234567890", "professor", "CST");
Assistant a("Li Chao", 011401, "Male", "1988-06-01", "12345619880601", "TA", "CST", "cst61", "computer science", &t);
cout << a.name << endl;
cout << a.id << endl;
cout << a.department << endl;
cout << a.class_num << endl;
cout << a.major << endl;
cout << a.advisor->name << endl;
return 0;
}
```
输出结果:
```
Li Chao
11401
CST
cst61
computer science
Zheng Li
```