问题 填空题

下列程序的运行结果是______。 #include<iostream.h> class Sample { int a; public: Sample(int aa=0){a=aa;} ~Sample( ){cout~<<"Sample="<<a<<’’;} }; class Derived:public Sample { int b; public: Derived(int aa=0,int bb=0):Sample(aa)(b=bb;} ~Derived( ){cout<<"Derived="<<b<<";} }; void main( ) { Derived d1(9); }

答案

参考答案:Derived=0 Sample=9

解析: 本题考察派生类和基类的构造函数,析构函数的执行顺序。

填空题
单项选择题