首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class AA { int a; public: int getRef()const{ return. &a,) //① int getValue()const{ return a;)
有如下类定义: class AA { int a; public: int getRef()const{ return. &a,) //① int getValue()const{ return a;)
admin
2018-12-04
88
问题
有如下类定义:
class AA
{
int a;
public:
int getRef()const{ return. &a,) //①
int getValue()const{ return a;) //②
void set(int n)const{ a=n;) //③
friend一void show(AA aa)const{ cout<<a,} //④
};
其中的四个函数定义中正确的是( )。
选项
A、①
B、②
C、③
D、④
答案
B
解析
此题考查了常成员函数和友元函数的概念。选项A中,getRef()函数的返回值和函数函数类型不符,故错误;C选项中set()常成员函数改变了数据成员的值,这是不允许的;D选项中show()函数被同时定义成友元函数和常成员函数是错误的。
转载请注明原文地址:https://www.kaotiyun.com/show/PgAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为______。#include<iostream.h>classtest{private:inthum;public
阅读以下程序#include<iostream.h>voidmain(){charline[10];cin>>line;cout<<line<<endl;}如运行时输入Thisise
关于友元的描述中错误的是
有以下程序main(){inti=10,j=1;cout<<--<<","<<++j<<endl;}执行后输出结果是
下列叙述中,错误的是
派生类构造函数的执行顺序是先执行______的构造函数,然后执行成员对象的构造函数,最后执行______的构造函数。
有如下程序:#include(iostream>usingnamespacestd;ClassTest{public:Test(){n+=2;}~Test(){n-=3;)s
关于纯虚函数,下列表述中正确的是()。
有如下类声明:classXA{intX;public:XA(intn){x=n;}};classXB:publicXA{inty;public:XB(inta,intb)
随机试题
符合高能磷酸键的叙述是
滤过分数是指
宜在清晨服用的药物有()。
下列表述中错误的是()。
本地杂草野花由于经历了千百年的自然?_______,对当地气候和土质都有极好的适应性,根本不需要过多额外的养护。而且,与属于外来物种的人工草坪相比,本地杂草野花还有一个_______就是生态安全。依次填入画横线部分最恰当的一项是:
利用虚拟技术进行设备管理的主要目的是()。
おなかの________が悪いので、ごはんは食べられない。
Theword"threatened"inthefirstsentenceofthefirstparagraphcouldbebestreplacedbyThefirstword"He"inparagraph6
HitlerwantedtoinvadeEngland【56】couldnotdosountiltheRAFwasdestroyed.InAugust1940theGermansbegandaylightbombin
Bigdatacanbedefinedasinformationthatistoobigorcomplextobecontainedorprocessedbyanyonemachineorperson.
最新回复
(
0
)