首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespaee std; class Base{ int x; public: Base(int n=0):x(n){eout
有如下程序: #include using namespaee std; class Base{ int x; public: Base(int n=0):x(n){eout
admin
2015-07-24
26
问题
有如下程序:
#include
using namespaee std;
class Base{
int x;
public:
Base(int n=0):x(n){eout<
int getX()eonst{return x;}
};
class Derived:public Base{
int y;
public:
Derived(int m,int n):y(m),Base(n){eout<
Derived(int m):y(m){eout<
};
int main()
{
Derived d1(3),a2(5,7);
return 0;
}
执行这个程序的输出结果是( )。
选项
A、375
B、357
C、0375
D、0357
答案
C
解析
本题考查派生类的构造函数和析构函数,在定义一个派生类的对象时,先调用基类的构造函数,然后再执行派生类的构造函数,对象释放时,先执行派生类的析构函数,再执行基类的析构函数。本题中定义了一个对象d1,先执行基类的构造函数输出O,再执行派生类的构造函数输出3,然后定义了一个对象d2(5,7),其中需要调用基类的构造函数输出7,最后输出5,所以答案为C。
转载请注明原文地址:https://jikaoti.com/ti/DQE0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在面向对象的设计中,用来请求对象执行某一处理或回答某些信息的要求称为【】。
下面程序输出的结果为 #include"iostream.h" classA { public: A(){cout<<"CLASSA"<<end1;} ~A(){} }; class
下面程序的结果是 #include"iostream.h" voidmain() { char*str; Str="test!"; cout<<str[5]; }
函数inttest(inta,intb=1,intc:0),下列调用不合法的个数是 test(0); test(0,0); test(); test(0,0,0);
有如下程序#include<iostream.h>voidmain(){charch[2][5]={"6937","8254"},*p[2];inti,j,S=0;f
请在mian函数中填空使下面程序的输出结果为11。 #include<iostream.h> classA {private: inta; intb; public: A():a(0),b(1){
进行文件操作时需要包含()文件。
()是给对象取一个别名,它引入了对象的同义词。
在深度为5的满二叉树中,叶子结点的个数为
面向对象程序设计思想的主要特征中不包括
随机试题
下列听证必须公开举行的是()
(2003年第16题)影响神经系统发育最重要的激素是
不会引起尿本周氏蛋白阳性的疾病是
无应激试验的目的是
蛛网膜下腔出血明确有脑动脉瘤,防止再出血的方法
受血者配血试验的血标本必须是输血前几天的
一般来说,发生债务危机的国家有以下几个特征()。
自行建造投资性房地产过程中发生的非正常损失直接计入当期损益,不计入建造成本。()
甲患有抑郁症导致性格偏执,产生报复心理。某日,甲用事前准备的刀重伤了路人乙。对于甲刑事责任能力的认定,下列哪一选项是正确的?()
在我国新民主主义革命时期,爱国主义主要表现为致力于推翻帝国主义、封建主义和官僚资本主义的反动统治;在现阶段,爱国主义主要表现在献身于建设和保卫社会主义现代化事业,献身于促进祖国统一大业。说明了
最新回复
(
0
)