#include <iostream>
using namespace std;
class father
{
public:
father(){cout<<"构造父亲类!"<<endl;}
void smart(){cout<<"父亲很聪明!"<<endl;}
virtual ~father(){cout<<"析构父亲类!"<<endl;}
};
class mother
{
public:
mother(){cout<<"构造母亲类!"<<endl;}
virtual void beautiful(){cout<<"母亲很漂亮!"<<endl;}
virtual ~mother(){cout<<"析构母亲类!"<<endl;}
};
class son:public father,public mother
{
public:
son(){cout<<"构造儿子类!"<<endl;}
void beautiful(){cout<<"儿子也很英俊!"<<endl;}
~son(){cout<<"析构儿子类!"<<endl;}
};
int main()
{
father*pf;
mother*pm;
int choice=0;
while(choice<99)
{
bool quit=false;
cout<<"[0]退出[1]父亲[2]儿子:";
cin>>choice;
switch (choice)
{
case 0:
quit=true;
break;
case 1:
pf=new father;
break;
case 2:
pm=new son;
pm->beautiful();
pf->smart();
delete pm;
break;
default:cout<<"请输入从0到2之前的数"<<endl;
}
if (quit==true)
{
break;
}
}
cout<<"程序结束!"<<endl;
return 0;
}