首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有下列程序,在横线添加; #include<iostream> using namespace std; class TestClass { public: TestClass (int n){number=n;}
有下列程序,在横线添加; #include<iostream> using namespace std; class TestClass { public: TestClass (int n){number=n;}
admin
2010-06-06
60
问题
有下列程序,在横线添加; #include<iostream> using namespace std; class TestClass { public: TestClass (int n){number=n;} ______//拷贝构造函数 ~TestClass(){} private: int number; }; TestClass fun(TestClass p) { TestClass temp(P); return temp; } int main() { TestClsss obj1(10),obj2(0); TestClass obj3(obj1); obj2=fun(obj3); return 0; }
选项
A、TestClass(TestClass &other){number=other.number;}
B、TestClass(TestClass other){number=other.number;}
C、TestClass(TestClass &other){number;}
D、TestClass(&other){number=other.number;}
答案
A
解析
拷贝构造函数中的赋值构造函数也是构造函数,但它只有一个参数,这个参数是本类的对象,即other,所以赋值操作将本类的参数other,number赋值给number;而且采用对象的引用的形式,也就是& other。
转载请注明原文地址:https://kaotiyun.com/show/rMjp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下定义structst{inta;floatb;}x[10];FILE*fp;若文件已正确打开,且数组x的10个元素均已赋值,以下将数组元素写到文件中的语句错误的是
有以下程序:#includemain(){intx,y=0,z=0,t;do{seanf(“%d”,&x);t=x>0:switch(t){ease0:brea
有以下程序,其中%u表示按无符号整数输出()。main(){unsignedintx=0xFFFF;/*x的初值为十六进制数*/printf("%u\n",x);}程序运行后的输出结果是()。
有三个关系R、S和T如下:由关系R和S通过运算得到关系T,则所使用的运算为()。
对长度为n的线性表作快速排序,在最坏情况下,比较次数为()。
设循环队列的存储空间为Q(1:35),初始状态为front=rear=35。现经过一系列入队与退队运算后,front=15,rear=15,则循环队列中的元素个数为
有以下定义语句,编译时会出现编译错误的是()。
设文件指针fp已定义,执行语句fp=fopen("file","w");后,以下针对文本文件file操作叙述选项中正确的是()。
算法的时间复杂度是指()。
以下选项中不能在C语言程序中用作用户标识符的是()。
随机试题
一个良好的决策目标应具备的条件有()
A.肝B.胆C.三焦D.心“谋虑出焉”是指
关于目视助航标志的叙述,正确的有()。
()是指证券价格能够充分反映价格历史序列中包含的所有信息,如证券的价格、交易量等。
海运提单
简述马丁.路德宗教改革的原因、内容和意义。
(1)将当前文件夹下的自由表class(班级表)和teacher(教师表)添加到学生数据库sdb中。(2)为班级表class创建一个主索引和普通索引(升序),主索引的索引名和索引表达式均为“班级号”;普通索引的索引名和索引表达式均为“班主任号”。为教师表
以下叙述中错误的是()。
AborntobemoreintelligentorlessintelligentBhaveabetterchancetodevelophisintelligenceCtaughttobemoreintelli
Readthetextbelow.Writeanessayinabout120words,inwhichyoushouldsummarizethekeypointsofthetextandmakecommen
最新回复
(
0
)