#include<stdarg.h>
#include<iostream>
#include<string>
using namespace std;
class Data_Rec
{
protected:
string n_name;
int i_ID;
public:
Data_Rec(string,int);
};
Data_Rec::Data_Rec(string name,int ID):n_name(name),i_ID(ID){}
class Employee:virtual public Data_Rec
{
protected:
char *d_department;
int s_salary;
public:
Employee(string name,int ID,char *dep,int salary);
void output();
};
Employee::Employee(string name,int ID,char *dep,int salary):Data_Rec(name,ID),d_department(dep),s_salary(salary){}
void Employee::output()
{
cout<<"姓名 \t"<<n_name<<"\nID\t"<<i_ID<<"\n部门\t"<<d_department<<"\n工资\t"<<s_salary<<endl;
}
class Student:virtual public Data_Rec
{
protected:
string m_major;
int s_sno;
int s_scare;
public:
Student(string name,int ID,string major,int sno,int scare);
void output();
};
Student::Student(string name,int ID,string major,int sno,int scare):Data_Rec(name,ID),m_major(major),s_sno(sno),s_scare(scare){}
void Student::output()
{
cout<<"姓名 \t"<<n_name<<"\nID\t"<<i_ID<<"\n专业\t"<<m_major<<"\n学号\t"<<s_sno<<"\n总成绩\t"<<s_scare<<endl;
}
class Teacher:public Employee
{
protected:
string r_resume;
public:
Teacher(string name,int ID,char *dep,int salary,string resume);
void output();
};
Teacher::Teacher(string name,int ID,char *dep,int salary,string resume):Data_Rec(name,ID),Employee(name,ID,dep,salary),r_resume(resume){}
void Teacher::output()
{
cout<<"姓名 \t"<<n_name<<"\nID\t"<<i_ID<<"\n部门\t"<<d_department<<"\n工资\t"<<"简历"<<r_resume<<endl;
}
class E_Student:public Employee,public Student
{
protected:
int Increase_salary;
public:
E_Student(string name,int ID,char *dep,int salary,string major,int sno,int scare,int In);
void output();
};
E_Student::E_Student(string name,int ID,char *dep,int salary,string major,int sno,int scare,int In):Data_Rec(name,ID),Employee(name,ID,dep,salary),Student(name,ID,major,sno,scare),Increase_salary(In){}
void E_Student::output()
{
cout<<"姓名 \t"<<n_name<<"\nID\t"<<i_ID<<"\n部门\t"<<d_department<<"\n工资\t"<<s_salary<<"\n专业\t"<<m_major<<"\n学号\t"<<s_sno<<"\n总成绩\t"<<s_scare<<"\n增加薪酬\t"<<Increase_salary<<endl;
}
void main()
{
Teacher te1("math",001,"信工学院",30000,"我是数学老师,毕业于北京大学");
Teacher te2("engliseh",002,"信工学院",30000,"我是英语老师,毕业于清华大学");
Teacher te3("c++",003,"信工学院",30000,"我是c++老师,毕业于电子科技大学");
Teacher te4("map",004,"信工学院",30000,"我是地图学老师,毕业于中国地质大学");
te1.output();
te2.output();
te3.output();
te4.output();
E_Student e1("a",005,"信工学院",0,"地理空间信息工程",1,720,0);
E_Student e2("b",006,"信工学院",10000,"地理空间信息工程",1,1000,3000);
e1.output();
e2.output();
}
这样写前面的cout好像没用,重复了,怎末一级一级的输出,而不是在最后输出。