首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class XCF{ int a: public: XCF(int aa=0):a(aa){cout
有如下程序: #include #include using namespace std; class XCF{ int a: public: XCF(int aa=0):a(aa){cout
admin
2019-04-01
14
问题
有如下程序:
#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";}
~XCF(){cout<
int Geta(){return a;}
};
int main(){
XCF d1(5),d2(d1);
XCF*pd=new XCF(8);
cout<
Geta();
delete pd;
return 0:
}
运行时的输出结果是( )。
选项
A、1215588
B、1218855
C、12185
D、128512
答案
B
解析
在这个程序中在建立对象d1(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<<"1";},输出1;语句cout<
Geta()的功能是输出8:语句delete pd;调用析构函数~XCF(),输出8;当退出程序时,分别释放对象d2、d1,输出55。
转载请注明原文地址:https://jikaoti.com/ti/Mjt0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下程序中调用cin函数给变量a输入数值的方法是错误的,其错误原因是#include<iostream.h>voidmain(){int*p,*q,a,b;p=&a;cout<<
下列程序的输出结果是#include<iostream.h>intmin(inta,intb){if(a<b)retuma;elsereturnb;return0;}
下面程序的运行结果为#include<iostream.h>voidmain(){for(inta=0,x=0;!x&&a<=10;a++){a++;
树中度为零的结点称为______。
有以下程序:#include<iostream>usingnamespacestd;classsample{private:intx;public:sample(intA){
有以下类定义:classA{char*a;public:A():a(0){}A(char*aA){//把aa所指字符串复制到a所指的存储空间a=______;strcpy(a
下列关于类和对象的叙述中,错误的是
在深度为6的满二叉树中,度为2的结点个数为______。
关于结构化程序设计原则和方法的描述错误的是()
对于长度为n的有序线性表,在最坏情况下,二分法查找只需比较______次。
随机试题
A.胸膜顶B.胸膜腔C.胸腔D.纵隔E.肋膈隐窝肋胸膜与膈胸膜相互转折处,称为
设计过程中,需要在不同设计阶段之间进行纵向的反复协调,这种协调( )。
施工过程分部工程质量验收应符合哪些规定( )。
在儿童的食谱制定中,()常常是最容易产生的问题。
已知Rt△ABC的三边长为等差数列{an}的连续三项,且数列的公差大于零.则此直角三角形的最小边a与公差d的关系为().
4,5,14,33,80,()
Man:Haveyouheardit?Johnhasjustbeenpromotedagain!Woman:He’stheboss’sblue-eyedboyatthepresent.Question:Whatd
从狭义上理解,马克思主义是()
若关系模式R的规范化程度达到4NF,则R的属性之间不存在非平凡且非【】的多值依赖。
1AftertheUnitedStatespurchasedLouisianafromFrance,PresidentJeffersoncalledforanexpeditiontoexplorethenewterri
最新回复
(
0
)