问题
单项选择题
下面程序的结果是 #include<iostream.h> class A { public:A(){cout<<"construtA" <<endl;}virtual ~A() {cout << "destructA" <<endl;}}; class B:public A { }; class C:public A { }; class D:public B,public C { }; void main() { Dd;}
A.constructA
B.constructA
C.constmctA
D.constmctA destructAconstructA constmctA constructA destructAconstructA constructA destructAdestructA constructA destructA destmctA destmctAdestructA destmctA destructA
答案
参考答案:B
解析: 类D继承了类C和类B,所以在构造的时候分别构造类B和类C。