public,private
#include <iostream>#include <string>
using namespace std;
class Teacher
{
string name;
int age;
string sec;
string address;
int phone;
string title;
public:
void getna();
void getag();
void getse();
void getad();
void getph();
void getti();
void display();
};
class Cadre
{
string name;
int age;
string sec;
string address;
int phone;
string post;
public:
void getna();
void getag();
void getse();
void getad();
void getph();
void getpo();
void display_1();
};
class Teacher_Cadre:public Teacher,public Cadre //变成 class Teacher_Cadre:public Teacher,protected Cadre
{
int wages;
public :
void getwa();
void show();
};
void Teacher::getna()
{
cout <<"putin the teacher's name:";
cin>>name;
}
void Teacher::getag()
{
cout <<"putin the teacher's age:";
cin>>age;
}
void Teacher::getse()
{
cout <<"putin the teacher's sec:";
cin>>sec;
}
void Teacher::getad()
{
cout <<"putin the teacher's address:";
cin>>address;
}
void Teacher::getph()
{
cout <<"putin the teacher's phone:";
cin>>phone;
}
void Teacher::getti()
{
cout <<"putin the teacher's title:";
cin>>title;
}
void Teacher::display()
{
cout<<"name:"<<name<<"age:"<<age<<"sec:"<<sec<<"title:"<<title<<"address:"<<address<<"phone:"<<phone;
}
void Cadre::getna()
{
cout <<"putin the teacher's name:";
cin>>name;
}
void Cadre::getag()
{
cout <<"putin the teacher's age:";
cin>>age;
}
void Cadre::getse()
{
cout <<"putin the teacher's sec:";
cin>>sec;
}
void Cadre::getad()
{
cout <<"putin the teacher's address:";
cin>>address;
}
void Cadre::getph()
{
cout <<"putin the teacher's phone:";
cin>>phone;
}
void Cadre::getpo()/*class Teacher_Cadre:public Teacher,public Cadre变成 class Teacher_Cadre:public Teacher,protected Cadre 这里为什么不让定义 */
{
cout <<"putin the teacher's post:";
cin>>post;
}
void Cadre::display_1()
{
cout<<"post:"<<post;
}
void Teacher_Cadre::getwa()
{
cout <<"putin the Teacher_Cadre'wages:";
cin>>wages;
}
void Teacher_Cadre::show()
{
display();
display_1();
cout<<"wages:"<<wages;
}
int main()
{
Teacher_Cadre a;
a.Teacher::getna();
a.Teacher::getag();
a.Teacher::getse();
a.Teacher::getad();
a.Teacher::getph();
a.getpo();//class Teacher_Cadre:public Teacher,public Cadre变成 class Teacher_Cadre:public Teacher,protected Cadre之后,怎么改就对了?
a.getti();
a.getwa();
a.show();
return 0;
}