首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class XCF{ int a; public: XCF(int aa=0):a(aa){cout<<”1
有如下程序: #include #include using namespace std; class XCF{ int a; public: XCF(int aa=0):a(aa){cout<<”1
admin
2020-04-07
76
问题
有如下程序:
#include
#include
using namespace std;
class XCF{
int a;
public:
XCF(int aa=0):a(aa){cout<<”1”;)
XCF(XCF&X){a=x.a;cout<<”2”;)
-XCFO{cout<
int Geta0{return a;}
};
int main(){
XCF dl(5),d2(d1);
XCF*pd=new XCF(8);
cout<<pd一>Geta0;
delete pd;
return 0:
)
运行时的输出结果是( )。
选项
A、1215588
B、1218855
C、12185
D、128512
答案
B
解析
在这个程序中在建立对象dl(5)时,调用构造函数XCF (int aa=0):a(aa){cout<<“1”;},输出1;在建立d2(d1)时,调用拷贝构造函数XCF(XCF&x){a=x.a;cout<<“2”;},输出2:在建立new xcF(8)对象时,调用构造函数XCF(int aa=0):a(aa){cout<<“l”;},输出l;语句cout<
Geta()的功能是输出8;语句delete pd;调用析构函数~XCF(),输出8;当退出程序时,分别释放对象d2、d1,输出55。
转载请注明原文地址:https://kaotiyun.com/show/Gw8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下面程序输出的结果是#include<iostream.h>voidmain(){inti;inta[3][3]={1,2,3,4,5,6,7,8,9};fo
C++语言的跳转语句中,对于break和continue说法正确的是()。
若有以下程序:#include<iostream>usingnamespacesstd;classA{public:A(){}A(inti)
数据库管理系统DBMS中用来定义模式、内模式和外模式的语言为
下列程序的输出结果为2,请将程序补充完整。#include<iostream>usingnamespacestd;classBase{public:【】voidfun(){cout<<
假定A为一个类,则语句A(A&a);为该类______函数的原型说明。
有如下类声明:classXA{intx;public:XA(intU)}x=n;}};classXB:publicXA{inty;public:XB(in
设x,y,t均为int型变量,执行语句:x=y=3;t=++x||++y;,完成后,y的值为( )。
下列叙述中正确的是()。
随机试题
机动车不得在隧道中超车。
供电线路常采用________方法来提高功率因数。
____________是指网络中的计算机设备可以与其他设备根据需要任意相连,两个网络节点可以直接通信,也可以通过其他节点进行转接。
患者,右眼行白内障摘除人工晶体植入术后视力逐渐减退,检查右眼角膜清亮,人工晶体位置正,但后囊混浊,眼底模糊窥不清。
一个项目建成的标志是多方面的,一般总结为“四个建成”,具体是指()
讲授法可以具体分为()几种方式
设f(χ)在[1,2]上连续,在(1,2)内可导,且f(χ)≠0(1<χ<2),又存在且非零,证明:(1)存在ξ∈(1,2),使得(2)存在η∈(1,2),使得∫12f(t)dt=ξ(ξ-1)f′(η)ln2.
Despiteyourbestintentionsandefforts,itis【C1】______:Atsomepointinyourlife,youwillbewrong.【C2】______canbehard
数据库技术的根本目标是()。
A、Theyareconsideredasfashionableitems.B、Theykeeppeopleclosertoeachother.C、Theyaremoreconvenienttousersthanfi
最新回复
(
0
)