首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class TV{ public: TV(int s=41):size(
有如下程序: #include #include using namespace std; class TV{ public: TV(int s=41):size(
admin
2019-03-05
40
问题
有如下程序:
#include
#include
using namespace std;
class TV{
public:
TV(int s=41):size(s) { cout<<’N’; }
TV(const TV& t):size(t.size) { cout<<’C’; }
~TV() { cout<<’D’; }
void Print() const { cout<
private:
int size;
};
int main(){
TV room1(41),room2(room1);
TV *room3=new TV(54);
room3->Print();
delete room3;
return 0;
}
运行时的输出结果是
选项
A、NC54
B、NCN54D
C、NNN54DDD
D、NCN54DDD
答案
D
解析
本题考查构造函数相关知识,本题中定义一个对象room1,输出N,定义room2时输出C,定义room3时输出N,然后执行room3.Print时,输出54,最后执行三个析构函数输出DDD,所以答案为D。
转载请注明原文地址:https://kaotiyun.com/show/LvAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下面对静态数据成员的描述中,正确的是
下面关于数组的描述错误的是
数据流图用于抽象描述一个软件的逻辑模型,数据流图由一些特定的图符构成。下列图符名标识的图符不属于数据流图合法图符的是
以下程序的输出结果是#include<iostream>usingnamespacestd;intmain(){cout.fill(’*’);cout.width(5);cous<<hex<<100<<end1;re
下列叙述中正确的是()。
根据注释内容在空白处填写适当内容。classLocation{private:intX,Y;public:voidinit(intinitX,intinitY);in
将关键字const写在函数头之后,函数体之前,说明该函数是一个const成员函数。此时const不是指定函数的返回值,而是修饰______指针。
下面程序的功能是将字符数组a中下标值为偶数的元素从小到大排列,其他元素不变,请填空。#include<iostream.h>#include<string.h>voidmain(){chara[]="clan
树是节点的集合,它的根节点数目是
已知一棵二叉树的先根序列为ABCDEFK,中根序列为DGBAFCK,则结点的后根序列为()
随机试题
Rumoristhemost【C1】______wayofspreadingstories—bypassingthemonfrommouth【C2】______mouth.Butcivilizedcountriesinn
A.根尖切除术根尖搔刮术B.髓底穿孔修补术C.根尖倒充填术D.根管侧穿修补术E.根尖诱导成形术GIC用于
提出病因假设的目的是为了
患者,女,27岁,孕42+2周,现规律宫缩2小时入院,胎心率为100次/分,流出的羊水呈黄绿色并黏稠,此时为其实施的护理措施中,最重要的是
下岗失业小额担保贷款可以向港、澳、台地区的下岗失业人员发放。()
下列企业中属于非法人组织的是()。
企业真正形成的标志是()。
A、 B、 C、 B[A]是fan,[B]是hand,[C]是pen。
TheBritishParliamenthasamaximumdurationof______years.
Althoughwearesufferingfromthenaturaldisaster,wewillovercomethedifficultyaslongaswedon’tloseheart.
最新回复
(
0
)