首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序,在横线应添加( )。 #include using namespace std; class TestClass { public: TestClass(int n){number=n;)
有以下程序,在横线应添加( )。 #include using namespace std; class TestClass { public: TestClass(int n){number=n;)
admin
2020-07-23
46
问题
有以下程序,在横线应添加( )。
#include
using namespace std;
class TestClass
{
public:
TestClass(int n){number=n;)
//拷贝构造函数
-TestClass(){}
private:
intnumber;
};
TestClass fun(TestClass p)
{
TestClass
选项
A、TestClass(TestClass&other){number=other.number;}
B、TestClass(TestClass other){number=other.number;}
C、TestClass(TestClass&other){number;}
D、TestClass r&other){number=other.number;}
答案
A
解析
拷贝构造函数也是构造函数,但它只有一个参数,这个参数是本类的对象,即other,所以赋值操作将本类的参数other.number赋值给number;而且采用对象的引用的形式,也就是&other。
转载请注明原文地址:https://kaotiyun.com/show/Rhyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
如果派生类以protected方式继承基类,则基类中的保护成员在派生类中的访问属性是
下面能作为软件需求分析工具的是
下列关于C++流的表述中,正确的是
下列选项中,与实现运行时多态性无关的是
下列字符串中,不可以用做C++标识符的是()。
下列字符串中可以用作C++标识符的是
下列各序列中不是堆的是
下面不属于软件需求分析阶段主要工作的是
T列符号中能够作为C++标识符的是()。
下列符号中不属于C++关键字的是()。
随机试题
患儿7岁,生病前体重21kg,近2天来频繁呕吐及腹泻。检查:体重19.5kg。四肢冰凉,尿少,血钠130mmol/L。根据以上情况,认为脱水程度及性质为
专治脾、肺气虚的药组是
重现期为100年一遇的洪水,是指这个量级的洪水在100年内()。
教师的积极情绪状态往往会_______到学生身上,使教师与学生的意图、观点与情感都联结起来,从而在师生间产生共鸣性的情感反应。
联觉,是指各种感觉之间的相互联系和影响,是一种感觉兼有另一种感觉的心理现象。联觉最常见的现象是通过温度、形状、气味、声音或味道感知色彩。比如,红、橙、黄。类似于太阳和烈火的颜色,往往引起温暖感,是一种暖色。蓝、青、紫,类似于碧空和寒水的颜色,常常引起寒冷感
learntoonornotA.Whetherwelikeit【T1】______B.haveto【T2】______acceptC.thatexists【T3】______planetEarthThe
ErnestHemingwaywasoneofthemostimportantAmericanwritersinthehistoryofcontemporaryAmericanliterature.Hewasthe【B
关于IP协议,______说法是错误的。
BeforeMikebecameanactor,whatkindofschooldidhegoto?
DevelopHealthyEatingHabitsinYourChildrenA)Whatdoyouthinkyourchildrenareservedatschool?Thechildrenwerese
最新回复
(
0
)