虚拟继承问题,求解疑问
#include <iostream>#include<String>
using namespace std;
class Teacher
{protected:
void show()
{
cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"address:"<<add<<endl;
}
string name;
string add;
int age;
int num;
string title;
};
class Cadre
{
public:
string name;
string add;
int age;
int num;
string post;
private:
};
class Teacher_Cadre:virtual public Teacher,virtual public Cadre
{ public:
void get();
void display();
int wages;
};
void Teacher_Cadre::display()
{
show();
cout<<title<<endl<<post<<endl<<wages;
}
void Teacher_Cadre::get()
{
cout<<"input num,name,add,age,title,post,wages:"<<endl;
cin>>num>>name>>add>>age>>title>>post>>wages;
}
int main()
{
Teacher_Cadre c;
c.get();
c.display();
return 0;
}