问题
填空题
下列程序的运行结果是 【15】 。
#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;
~De rived() cout <<"Derived="<<b<<’’;
void main()
Derived dl (9)
答案
参考答案:Derived=0 Sample=9
解析: 本题考察派生类和基类的构造函数,析构函数的执行顺序。