首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include <iostream> using namespace std; class sample { private: int n: public: sample () {}
有以下程序: #include <iostream> using namespace std; class sample { private: int n: public: sample () {}
admin
2013-05-30
49
问题
有以下程序: #include <iostream> using namespace std; class sample { private: int n: public: sample () {} sample(int m) { n=m; } sample add(sample s1, sample s2) this->n=s1.n+s2.n; return (*this); } void disp () { cout <<"n="<<n<<end1; } }; int main() sample s1(1)0,s2(5),s3; s3.add(s1,s2); s3.disp(); return 0; } 程序运行后,输出的结果是
选项
A、n=10
B、n=5
C、n=20
D、n=15
答案
D
解析
本题考核this指针的使用。类成员函数add中通过this指针实现私有数据成员n的赋值。
转载请注明原文地址:https://kaotiyun.com/show/7BNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列程序在构造函数和析构函数中申请和释放类的私有成员,请完成该类的实现。classMyclass{public:Myclass(intnum);~Myclass();public:int*p;};
数据库设计的四个阶段是:需求分析、______、概念设计和物理设计。
结构化分析的常用工具不包括______。
数据库系统中实现各种数据管理功能的核心软件称为【】。
在设计程序时,应采纳的原则之一是()。
下列叙述中,正确的是()。
数据库管理系统常见的数据模型有层次模型、网状模型和【】三种。
数据库DB、数据库系统DBS、数据库管理系统DBMS之间的关系是()。
在数据库系统的内部结构体系中,索引属于()。
在数据库系统的内部结构体系中,索引属于()。
随机试题
ItiscommonlybelievedthatthegreatEnglishdramatistandpoetWilliamShakespearewasborninStratford-on-AvononApril23,
汉地佛教的四大菩萨指的是()。
妊娠合并心脏病早期心衰的表现是
肾性贫血微血管病性贫血
根据《中华人民共和国野生动物保护法》对野生动物保护的有关规定,下列说法正确的是()。
关于累进税率,下列说法中错误的是()。
Practicallyallspeciesofanimalscommunicateeitherthroughsoundsorthroughalargerepertoryofsoundlesscodes.
AstudybyscientistsinFinlandhasfoundthatmobilephoneradiationcancausechangesinhumancellsthatmightaffectthebr
Walkingistheexerciseofchoiceformostdieters.Nowonder.Youdon’tneedagymmembership.Youcandoitvirtuallyeverywhe
ArecentBBCdocumentary,"TheTownThatNeverRetired",soughttoshowtheeffectsofincreasingthestatepensionagebyputti
最新回复
(
0
)