首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class Father{ public: Father(string
有如下程序: #include #include using namespace std; class Father{ public: Father(string
admin
2021-06-10
18
问题
有如下程序:
#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://kaotiyun.com/show/Zkfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
假定在一个程序中执行到语句:cout
当派生类从一个基类保护继承时,基类中的一些成员在派生类中成为保护成员,这些成员在基类中原有的访问属性是
对于语句cout
下列函数的运行结果是()。includeintf(inta,intb){intc;if(a>b)c=1:elseif(a==b)c=0:elsec=-1:return(c)
使用VC6打开考生文件夹下的源程序文件modi3.clap。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能:(1)定义类CPoint的带有两个参数的构造函数,两个变量为x、y都为int型,且缺省值为0。请在注释∥*******
请打开考生文件夹下的解决方案文件proj3,其中定义了Mystring类,一个用于表示字符串的类。成员函数reverse的功能是将字符串进行“反转”。例如,将字符串ABCDEF“反转”后,得到字符串FEDCBA;将字符串ABCDEFG“反转”后,得到字符串
请打开考生文件夹下的解决方案文件proj1,该工程中包含程序文件main.cpp,其中有关TVSet(“电视机”)和主函数main的定义。程序中位于每个“//ERROR***********found***********”之后的一行语句有错误,请加以改
下列符号中能够作为C++标识符的是()。
下列叙述中正确的是()。
软件(程序)调试的任务是()。
随机试题
焦点团体座谈会、头脑风暴法、德尔菲函询法等属于
TheintelligencetestusedmostoftentodayarebasedontheworkofaFrenchman,AlfredBinet.In1905,Binetwasaskedbythe
A.肱骨外科颈骨折B.肱骨干中上1/3骨折C.肱骨干中下1/3骨折D.伸直型肱骨髁上骨折可能损伤桡神经的骨折是
男性,29岁。转移性右下腹痛伴发热36小时入院,诊断为急性阑尾炎。入院后腹痛加重,伴有寒战,体温40℃,巩膜轻度黄染,剑突下压痛,右下腹肌紧张,右下腹明显压痛、反跳痛,最可能的诊断是
消防用电设备供电线路当线路暗敷设时,要对所穿金属导管或难燃性刚性塑料导管进行保护,并要敷设在不燃烧结构内,保护层厚度不要小于()mm。
通过证券交易所的证券交易,投资者及其一致行动人拥有权益的股份达到一个上市公司已发行股份的5%时,应当编制权益变动报告书。完成权益变动报告书的期限是该事实发生之日起()日内。
职业判断对于适当地执行审计工作是必不可少的,对于作出下列()决策尤为必要。
教育目的由国家制定,培养目标由学校制定,教学目标由教师制定。
火车轰隆轰隆地开(1),开往山里。火车要(2)过一百零八十个山洞,这是这条支线当年修通时,我第一次经过时,一个个数的。我坐在火车上,毫无倦意,因为在铁路线的另一头,有一个我(3)中最重要的人——母亲在等着我。(1)
A、Studentsreceivecreditforworkexperience.B、Theprofessorvideotapesclasslecturesforreview.C、Classesareheldatvario
最新回复
(
0
)