首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
2020-04-07
20
问题
有如下类定义:
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://kaotiyun.com/show/fy8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
若有如下程序段:#includeusingnamespacestd;intmain(){char*p=“abcdefgh”,*r;r=p;cout
关于虚函数的描述中正确的是
程序段的输出结果是【】。intx=3,y=2,z=1;count<<(x/y&~z);
在数据的存储结构中,不仅需要存储各数据元素的信息,还要存放各元素之间______________的信息。
下列是重载乘法运算符的函数原型声明,其中错误的是( )。
为了避免嵌套的if…else语句的二义性,C++规定与else配对的是
数据结构分为逻辑结构与存储结构,线性链表属于【】。
下列选项中不属于软件生命周期开发阶段任务的是()。
程序设计语言的工程特性之一为()。
在关系数据库中,用来表示实体间联系的是
随机试题
A.快速、精确而短暂B.快速、粗糙而广泛C.缓慢、持久而弥散D.相对局限和不灵敏体液调节的一般特点是
屏蔽高频电磁场的材料最好选用
A.脂瘤B.气瘤C.血瘤D.肉瘤E.筋瘤相当于下肢静脉曲张的是
不属于建筑工程施工合同合同管理的原则是()。
残疾人的基本需求包括()。
我国法律主要体现的是()的意志。
根据《中华人民共和国公司法》规定,________不具有独立法人资格。
检索所有比“王华”年龄大的学生姓名、年龄和性别。正确的SELECT语句是______。
A、收入不高B、尚不规范C、发展比较慢D、是服务行业D
Arapidmeansoflong-distancetransportationbecameanecessityfortheUnitedStatesassettlement(新拓居地)spreadeverfartherwe
最新回复
(
0
)