发布时间:2019-08-08 13:22:50
#include<iostream.h>#include<string.h>class student{ private: int x; char y[16]; float z; public: student(int a,char b[16],float c) { x=a; strcpy(y,b); z=c; cout<<"调用学生类构造函数"<<endl; } void show() {cout<<"学号"<<x<<'\t'<<"姓名"<<y<<'\t'<<"分数"<<z<<endl;} ~student() {cout<<"调用学生析类构函数"<<endl;}};class teacher{ private: int q; char w[16]; float e; public: teacher(int u,char i[16],float o) { q=u; strcpy(w,i); e=o; cout<<"调用教师类构造函数"<<endl; } void show() {cout<<"职工号"<<q<<'\t'<<"姓名"<<w<<'\t'<<"工资"<<e<<endl;} ~teacher() {cout<<"调用教师类析构函数"<<endl;}};class stu_tea:public student,public teacher{ public: stu_tea(int a,char b[16],float c ,int u,char i[16],float o) :student(a,b[16],c),teacher(u,i[16],o) { strcpy(y,b) strcpy(w,i);} void show() {cout<<"职工号信息"<<endl;} ~stu_tea() {cout<<"调用助教类析构函数"<<endl;}};void main(){ stu_tea t(10001,"abc",88,10002,"chi",4000);t.student::show();t.teacher::show ();t.stu_tea::show ();t.student::~student ();t.teacher::~teacher ();t.stu_tea::~stu_tea ();}