首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
2020-06-29
56
问题
有如下程序:
#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/L6yp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
一棵二叉树共有25个结点,其中5个是叶子结点,则度为1的结点数为( )
有如下程序:#includeusingnamespacestd;classPoint{public:Point(intxx=0,intyy=0):x(xx),
有如下程序:#includeusingnamespacestd;voidf(intx,int&y){intz=x;x=y;y=z;}intmain(){
通过运算符重载,可以改变运算符原有的
有如下类定义:classBase{public:inta;protected:intb;private:intc;};classDe
数据库中对概念模式内容进行说明的语言是
为类MyClass重载赋值运算符时,应将其重载为类的
语句int*p=&k;定义了指针p,与这个语句等效的语句序列是()。
软件测试的目的是()。
随机试题
进程控制块包含()
放线菌属中对人有致病性的有
总量平衡与结构平衡之间的关系是()。
下列做法符合因地制宜原则,有利于可持续发展的是()。
定性研究者与定量研究者相比更可能()
Whatisthepurposeofthemessage?
Becauseofvariousburdens,the1980sinEcuadorbecameadecadeof______Itwasmadeworsebybadfloodsin1983,thecollapseo
Themanageratoncelosthis______whenhelearntthathissecretarywaslateagainforthemeeting.
WhichofthefollowingisNOTtrueaboutthetsunami?
Developmentbanksareinternationallendinggroups.Theylendmoneytodevelopingcountriestohelpfueleconomicgrowthandsoc
最新回复
(
0
)