首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Base{ public: Base(int x=0):valB(x){cout
有如下程序: #include using namespace std; class Base{ public: Base(int x=0):valB(x){cout
admin
2020-07-30
23
问题
有如下程序:
#include
using namespace std;
class Base{
public:
Base(int x=0):valB(x){cout<
~Base(){cout<
private:
int valB;
};
class Derived:public Base{
public:
Derived(int x=0,int y=0):Base(x),valD(y){cout<
~Derived(){cout<
private:
int valE);
};
int main(){
Derived obj 12(2,3);
return 0;
}
运行时的输出结果是( )。
选项
A、2332
B、2323
C、3232
D、3223
答案
A
解析
在主函数中创建类Derived对象obj12(2,3)时,因为类Derived是从基类Base派生而来,所以首先调用基类的构造函数,输出2,再调用派生类构造函数,输出3。当主函数运算结果时,首先调用派生类的析构函数,输出3,再调用基类的析构函数输出2。所以输出结果为2332。
转载请注明原文地址:https://kaotiyun.com/show/y3yp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
给定程序MODll.c中,函数fun()的功能是统计S所指一维数组中0的个数(存在变量zero中)和l的个数(存在变量orle中),并输出结果。请改正函数fun中指定部位的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行
下列给定程序中,函数fun的功能是:比较两个字符串,将长的字符串的首地址作为函数值返回。请改正程序中的错误,使它能得出正确的结果。注意:部分源程序在文件MODII.C中,不要改动main函数,不得增行或删行,也不得更改程序的结构!
请使用”答题”菜单或使用VC6打开考生文件夹proj1下的工程proj1,程序中位于每个//ERROR**********found**********下的语句行有错误,请加以更正,不得修改程序的其他部分。更正后程序的输出应该是:AT
下列语句都是程序运行时的第1条输出语句,其中一条语句的输出效果与其他三条语句不同,该语句是()。
下列有关内联函数的叙述中,正确的是()。
下列各组类型声明符中,含义相同的一组是()。
有三个关系R、S和T如下:由关系R和S通过运算得到关系T,则所使用的运算为()。
下面描述正确的是()。
下列哪项不是面向对象程序设计的主要特征()。
随机试题
管理评审的时间要求
下列哪项关于疾病监测的论述是错误的
金融凭证诈骗罪包括下列哪些情形之一?
下列关于企业投资项目可行性研究深度的说法中,错误的是()。
会计人员违反职业道德,情节严重的,由财政部门( )。
证券公司从事定向资产管理业务,应当与客户、资产托管机构签订定向资产管理合同,定向资产管理合同应当包括( )制定的合同必备条款。
反映获利能力对债务偿付的保证程度的指标是()。
咨询师对求助者的热情可以体现在()。
工人:农民:公民
研究表明,肿瘤的生长有以下规律:当肿瘤细胞数目超过1011时才是临床可观察的:在肿瘤生长初期,几乎每隔一定时间就会观测到肿瘤细胞数量翻一番;在肿瘤生长后期,肿瘤细胞的数目趋向某个稳定值。为此,图()反映了肿瘤的生长趋势。
最新回复
(
0
)