首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class Father{ public: Father(string
有如下程序: #include #include using namespace std; class Father{ public: Father(string
admin
2020-07-23
64
问题
有如下程序:
#include
#include
using namespace std;
class Father{
public:
Father(string s):name(s) { }
~Father() { cout<<’F’; }
private:
string name;
};
class Mother{
public:
Mother(string s):name(s) { }
~Mother() { cout<<’M’; }
private:
string name;
};
class Child:public Mother,public Father{
public:
Child(string s1,string s2,string s3,int a):Father(s1),Mother(s2),name(s3),age(a) { }
~Child() { cout<<’C’; }
private:
string name;
int age;
};
int main(){
Child son("Zhang","Li","Ming",20);
return 0;
}
运行时的输出结果是
选项
A、C
B、CMF
C、CFM
D、20CMF
答案
C
解析
执行派生类构造函数的顺序是:
1、调用基类构造函数,2、调用子对象构造函数,3、再执行派生类析构函数,4、执行基类的析构函数。所以本题中执行析构函数为派生类的析构函数、Father的析构函数、Mother的析构函数,所以输出CFM,答案C正确。
转载请注明原文地址:https://www.kaotiyun.com/show/whyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;classPair{intm,n;public:Pair(intj,intk):m(j),n(k){}intget(){returnm;}intget()
有如下4个语句:①cout
有如下程序:#include#includeusingnamespacestd;classWheel{public:Wheel(strings=
支持子程序调用的数据结构是( )。
下列叙述中正确的是( )。
在定义一个类模板时,模板形参表是用一对括号括起来的,所采用的括号是
下面不能作为结构化方法软件需求分析工具的是
若实体A和B是一对多的联系,实体B和C是一对一的联系,则实体A和C的联系是
下列符号中不属于C++关键字的是()。
下列特征中不是面向对象方法的主要特征的是()。
随机试题
从攻击的角度看,Kerberos存在哪些问题?
A.呕家之圣药B.温中散寒之至药C.温经而止血D.温肾散寒炮姜善于
贫血是指单位容积的外周血液中
阳性对比剂的特点,错误的是
案例 2007年10月,A煤矿6号采区1113东巷发生煤与瓦斯突出事故,造成19人死亡、2人受伤,直接经济损失600.4万元。 矿井采用斜井开拓,混合式通风,矿井总风量为8890m3/min,矿井负压为3100~3400Pa。开采B4单一煤层,2006
水利工程建设项目施工准备工作阶段监理工作的基本内容有()。
下列关于附带认股权债券的筹资成本表述正确的有()。
2016年10月17日,神舟()号奔向天宫,顺利将两名航天员送上太空执行与天宫2号交会对接任务。
CAVIL:CRITICIZE::
A、Beforebreakfast.B、Inthelatemorning.C、Inthelateafternoon.D、Inthelateevening.C
最新回复
(
0
)