首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class Father{ public: Father(string
有如下程序: #include #include using namespace std; class Father{ public: Father(string
admin
2015-07-22
20
问题
有如下程序:
#include
#include
using namespace std;
class Father{
public:
Father(string s):name(s) { cout<<’F’; }
~Father() { }
private:
string name;
};
class Mother{
public:
Mother(string s):name(s) { cout<<’M’; }
~Mother() { }
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) { cout<<’C’; }
~Child() { }
private:
string name;
int age;
};
int main(){
Child son("Zhang","Li","Ming",20);
return 0;
}
运行时的输出结果是
选项
A、C
B、FMC
C、MFC
D、FMC20
答案
C
解析
执行派生类构造函数的顺序是:
1、调用基类构造函数,2、调用子对象构造函数,3、再执行派生类析构函数,4、执行基类的析构函数。所以本题中执行构造函数为先执行基类Mother的构造函数、然后执行基类Father的构造函数,再执行派生类的构造函数函数,所以输出MFC,答案C正确。
转载请注明原文地址:https://jikaoti.com/ti/dwE0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
设i,j,k均为int型变量,则执行完for(i=0,j=10;i<=j;i++,j--)k=i+j;语句后,k的值为【】。
请指出在顺序表{2、5、7、10、14、15、18、23、35、41、52}中,用二分法查找关键码12需做()次关键码比较。
数据是指所有能输入到计算机之中并被计算机程序处理的()。
()是一个在百慕大类中说明的虚函数,它在该基类中没有定义,但要求任何派生类都必须定义自己的版本。
一个类可以从直接或间接的祖先中继承所有属性和方法。采用这个方法提高了软件的【】。
下面的叙述中,不符合赋值兼容规则的是()。
有如下程序#include<iostream.h>voidmain(){charch[2][5]={"6937","8254"},*p[2];inti,j,S=0;f
mystrlen函数的功能是计算str所指字符中的长度,并作为函数值返回,请填空。intmystrlen(char*str){inti;for(i=0;【】!=’\0’;i++);return(i);}
长度为n的顺序存储线性表中,当在任何位置上插入一个元素概率都相等时,插入一个元素所需移动元素的平均个数为【】。
下列语句不能够用于打开C根目录下文件test.txt的语句是
随机试题
简述聚氨酯泡沫防腐保温层的结构。
求椭圆锥面z2=x2+y2在点(1,1,1)处的法线方程
在招标程序中,()等将作为未来合同文件的组成部分。
某工厂生产A产品经过三个步骤,原材料在生产开始时一次投人,月末在产品按约当产量法计算,各步骤在产品完工程度均为50%。(1)有关产量记录见表1:(2)有关费用资料如表2:要求:(1)根据A产品的生产特点及成本管理的要求,A产品采用平行结转分
金融市场的参与者利用组合投资分散投资于单一金融资产所面临的系统性风险。()
导游讲解在导游服务中占主体地位,实地导游不仅不会被图文声像导游方式所替代,而且将永远在导游服务中处于主导地位,这是因为()。
下列教学方法的实施组织形式属于现场教学的是()。
认知策略这个术语最初是由美国心理学家布鲁纳提出来的。()
2015年2月,我国快递业务量完成8.2亿件;同比增长18.7%;业务收入完成136.0亿元,同比增长22.5%。消费者对快递业务进行的申诉中,有效申诉(确定企业责任的)占总申诉量的97.6%,为消费者挽回经济损失229.8万元。2015年2月,
【B1】【B8】
最新回复
(
0
)