首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序,在横线应添加( )。 #include<iostream> using narnespace std; class TestClass { public: TestClass int n){
有以下程序,在横线应添加( )。 #include<iostream> using narnespace std; class TestClass { public: TestClass int n){
admin
2020-11-11
65
问题
有以下程序,在横线应添加( )。
#include<iostream>
using narnespace std;
class TestClass
{
public:
TestClass int n){number=n;}
______∥拷贝构造函数
~TestClass (){}
private:
int number;
};
TestClass fun(TestClass p)
{
TestClass temp(p);
return temp;
}
int main()
{
TestClass 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(TestClms &other){number;}
D、TestClass(&other){number=other.number;}
答案
A
解析
拷贝构造函数也是构造函数,但它只有一个参数,这个参数是本类的对象,即other,所以赋值操作将本类的参数other.number赋值给number;而且采用对象的引用的形式,也就是&other。
转载请注明原文地址:https://www.kaotiyun.com/show/svyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在下列枚举符号中,用来表示“相对于当前位置”文件定位方式的是()。
下列关于栈的描述中错误的是()。
有如下程序:#include<iostream>usingnamespacestd;classMusic{public:voidsetTitle(char*str){strcpy(title,str
有如下程序:#inc1ude<iostream>usingnamespacestd;c1assComp1ex{doublere,im;public:Comp1ex(double
数据库技术的根本目标是要解决数据的()。
在面向对象方法中,不属于“对象”基本特点的是()。
下列代码段中声明了3个类:classPerson{};classStudent:publicPerson{};classUndergraduate:Student{};下列关于这些类之间关系的描述中,错误的是
下列各组类型声明符中,含义相同的一组是()。
下列数据流图(DFD)构造规则中正确的是
随机试题
下列对快速舒张期的叙述哪一项是错误的()
在证券内幕交易中,内幕信息需要两个构成要件,即()。
2007年4月30日,甲以手机短信形式向乙发出购买一台笔记本电脑的要约,乙于当日回短信同意要约。但由于“五一”期间短信系统繁忙,甲于5月3日才收到乙的短信,并因个人原因于5月8日才阅读乙的短信,后于9日回复乙“短信收到”。根据合同法律制度的规定,甲乙之间买
1972年中美上海《联合公报》:“美国认识到,在台湾海峡两边的所有中国人,都认为只有一个中国,台湾是中国的一部分。美国政府对这一立场不提出异议……”美国发表这一声明意在()。
马斯洛的需要层次论属于()
“平民情怀’’是指同情处于社会底层的人们,真诚关注他们的生存状态,自觉尊重维护他们合法权益的情怀。根据上述定义,下列文学作品中主要体现“平民情怀”的是()。
设y(x)是微分方程y’’+(x-1)y’+x2y=ex满足初始条件y(0)=0,y’(0)=1的解,则().
A、Shetookpartinsomesororitiestogetideas.B、Sherelatedherowncollegelifetotherole.C、ShecombinedAshleighwithso
Whatceremonyisthespeakeraddressing?The______ceremonyoftheInternationalArtsContest.
A、TeenagerslovetogotoFranceforaholiday.B、Thewomantriestoenjoyherholidaymorewithlessmoney.C、Thewomandecide
最新回复
(
0
)