#include <iostream>
#include<string>
#include<cstring>
using namespace std;
class student;
class teacher
{
private:
public:
teacher(){}
~teacher(){}
teacher(string n,int a,int s):name(n),age(a),object(s){}
teacher(const teacher& T)//拷贝构造
{
name = T.name;
age=T.age;
object=T.object;
}
teacher& operator=(const teacher& O)//拷贝赋值
{
name=O.name;
age=O.age;
object=O.object;
return *this;
}
protected:
string name;
int age;
int object;
};
class student
{
private:
public:
student(){}
~student(){}
student(string n,int a,int s):name(n),age(a),score(s){}
student(const student& T)//拷贝构造
{
name = T.name;
age=T.age;
score=T.score;
}
student& operator=(const student& O)//拷贝赋值
{
name=O.name;
age=O.age;
score=O.score;
return *this;
}
protected:
string name;
int age;
int score;
};
class graduate:public student,public teacher
{
private:
string sex;
public:
graduate(){}
~graduate(){}
graduate(string n,int a,int s,string na,int ag,int o,string se):student(n,a,s),teacher(na,ag,o),sex(se){}
graduate(const graduate& T):student(T),teacher(T),sex(T.sex){}
graduate& operator=(const graduate& O)//拷贝赋值
{
student::operator=(O);
teacher::operator=(O);
sex=O.sex;
return *this;
}
void show()
{
cout<<"name"<<student::name<<'\t'<<"sex"<<sex<<endl;
}
};
int main()
{
graduate gr("lizhou",18,90,"王钢蛋",36,100,"男"),gra("zhangdsan",8,99,"王铁蛋",46,1,"女");
graduate grad(gr);
gr=gra;
gr.show();
cout << "Hello World!" << endl;
return 0;
}