cout<C\n";}
~b2()
{cout<<"D\n";}
}
class derived:public b2,public b1{
public:
derived(int x,int y):b1(y),b2(x)
{cout<<"E\n";}
~derived(){cout<<"F\n";}
main(){
derived obj(5,7);
}
4、#include
class FATHER{
public:
virtual void answer( )
{cout< return;
}
}
class DAUGHTER:public FATHER{
public:
virtual void answer( )
{cout<<"I am daughter\n";
return;
}
}
class SON:public FATHER{
public:
void answer()
{cout<<"I am son\n";
return;
}
}
int main()
{ FATHER father;
DAUGHTER daughter;
SON son;
FATHER *who;
who=&father;
who->answer();
who=&daughter;
who->answer();
who=&son;
who->answer();
return 0;
}
(责任编辑:城市网)