填空题
下列程序的运行结果是{{U}} 【15】 {{/U}}。
#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)
}
【正确答案】
1、Derived=0 Sample=9
【答案解析】[解析] 本题考察派生类和基类的构造函数,析构函数的执行顺序。