本套試題重點考查考生對于多繼承中類的定義和派生類構(gòu)造函數(shù)的定義的掌握。注意學(xué)會使用參數(shù)列表的形式定義派生類的構(gòu)造函數(shù)。
29.下面程序的結(jié)果是( )
#include<iostream.h>
class test{ private:
int num;
public:
test();
int getint() {return num;}
~test();};
test::test()
{ num =0;}
test::~test()
{ cout<<″Destructor is active″<<endl;}
void main()
{ test x[3];
cout<<″Exiting main″<<endl;}
A.Exiting is actice
Destructor is active
Destructor is active
Destructor is active
B.Exiting main
Destructor is active
Destructor is active
C.Exiting main
Destructor is active
D.Exiting main
【參考答案】A
相關(guān)推薦:
C++考試輔導(dǎo):內(nèi)存分配的五種方法的區(qū)別 2009年c++二級等考輔導(dǎo):char*和char[]的區(qū)別