填空题
请按下面注释的提示将类B的构造函数定义补充完整。 class A { int a; public: A (int aa=0){a=aa;} }; class B: public A { int b; A c; public: // 用 aa 初始化基类 A, 用 aa+1 初始他类对象成员 c B(int aa):
【9】
{b=aa+2;} };
【参考答案】
A或者A(aa),c(aa+1)或者A或者c(aa+1],A(aa)
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
下列程序的输出结果是 【11】 。#include <iostream>using namespace std;class Test {public:Test() {cnt++;}~Test() {cnt--;}static int Count() (return cnt;}private:static int cnt;};int Test::cnt=0;int main(){cout<<Test::Count()<<’’;Test t1, t2;Test *pT3=new Test;Test *pT4=new Test;cout<<Test::Count()<<’’;delete pT4;delete pT3;cout<<Test::Count()<<end 1;return 0;}
点击查看答案&解析
填空题
下列程序的输出结果是 【10】 。#include <iostream>using namespace std;int main(){int i=5;iht & r=i;r=7;cout<<i<<end 1;return 0;}
点击查看答案&解析
相关试题
下列程序的输出结果是 【15】 。#incl...
下列程序输出结果是 【13】 。include...
与成员访问表达式p→name 等价的表达式是...
下面是用来计算n的阶乘的递归函数,请将该...