首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class Father{ public: Father(string
有如下程序: #include #include using namespace std; class Father{ public: Father(string
admin
2020-07-23
59
问题
有如下程序:
#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://kaotiyun.com/show/Dnyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下类定义:classMyClass{public:MyClass(doubled=0.0):val(d){}______________/
有如下程序:#includeusingnamespacestd;classSample{friendlongfun(Samples);public:Sample(longa){x=a;}private:long
有如下程序:#include#includeusingstd::cout;classPoint{public:frienddoubledi
有如下程序:#includeusingnamespacestd;voidf1(int&x,int&y){intz=x+y;x=y;y=z;}voidf2(intx,i
有如下程序:#includeusingnamespacestd;intmain(){intf,f1=1,f2=1;for(inti=0;i
在E-R图中,用来表示实体联系的图形是( )。
如果派生类以protected方式继承基类,则基类中的保护成员在派生类中的访问属性是
下列字符串中可以用作C++标识符的是
有如下说明:inta[10]={1,2,3,4,5,6,7,8,9,10},*p=a;则数值为9的表达式是()。
使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正程序中的错误,使得程序输出:10TestClass1注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//***
随机试题
腺垂体合成和分泌的促甲状腺激素(TSH)
在城镇道路的填土工程、城市桥梁的桥头接坡工程中常用到()挡土墙。
全面结算会员期货公司调整非结算会员结算准备金最低金额的,应当在()向期货交易所和期货保证金安全存管监控机构报告。[2011年11月真题]
某企业上年销售收入为4000万元,总成本为3000万元,其中固定成本为600万元。假设今年该企业变动成本率维持在上年的水平,现有两种信用政策可供选用:甲方案的信用政策为(2/10,1/20,N/90)。预计销售收入为5400万元,将有30%的货款于
一般资料:求助者,男性,29岁,未婚,本科毕业,工程师。案例介绍:求助者大学毕业后进入一家国企任职,工作稳定。近期企业招聘了一些硕士研究生,求助者为自己学历低感到有些自卑。2个多月前,在某技术问题上与新同事产生分歧,领导最终选择了同事的设计方案,
程序教学是根据()原理设计出来的。
某水产公司1996年产值为2000万元,2003年产值为1996年的300%,则年平均增长速度及年平均增长量为()。
下列关于计算机病毒的叙述中,正确的是
WhenKatewaseighteenyearsofage,hermothergaveherabeautifulring.ItwasabirthdaypresentandKatewasverypleased.
Indiansalwaysshake(摇)theirheadstheytalktoothers.【C1】______doesnothavethesamemeaning【C2】______"no".Ifsomeonewants
最新回复
(
0
)