首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
如下类定义: 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
2015-07-22
34
问题
如下类定义:
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、①
B、②
C、③
D、④
答案
B
解析
本题考查常成员函数,常成员函数只能引用本类中的数据成员,而不能修改它。所以本题答案为B。
转载请注明原文地址:https://kaotiyun.com/show/J5Np777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序 #include <iostream> using namespace std; class A{ public: virtual void funcl( ){ cout<<"A1"; } v
有如下程序:#include<iostream>usingnamespacestd;classCA{public:CA()<cout<<’A’;)};classCB:privateCA{public:CB(){co
已知如下程序的输出结果是23,请将画线处缺失的部分补充完整。#include<iostream>usingnamespacestd;classMyClass{public:voidPrint()
已知有函数f的定义如下:intf(){staticints=0;s+=2;returns;}则在某程序中第2次执行函数调用语句f();时,函数f的返回值是【】。
如下程序声明了一个使用两个通用数据类型的模板类dataClass,其中构造函数用于初始化两个数据成员,成员函数show用于输出两个数据成员的数值。#include<iostream>usingnamespacestd;【
随机试题
A、3~6gB、3~9gC、1~2gD、0.5~1.5gE、0.3~0.6g生天南星的内服用量是
证券公司为加强自律管理,应严格保密纪律,有机会获取内幕信息的从业人员不泄露、不利用内幕信息。()
中国对外政策的基本立足点是()。
(2011年福建.春.材料二)根据以下资料,回答下列问题。2007年两国碳排放量之和比2006年两国碳排放量之和约增加了()。
有以下程序#includemain(){inta,b;for(a=0;a
下列程序用于将源文件中的字母进行大小写转换,while的条件是【 】。#include<iostream.h>#include<fstream.h>#include<iomanip.h>void
有如下程序:#include<iostream>usingnamespacestd;intmain(){charstr[100],*P;cout<<"pleaseinputastring:
考生文件夹下存在一个数据库文件“samp3.accdb”,里面已经设计了表对象“tEmp”和窗体对象“fEmp”。同时,给出窗体对象“fEmp”上“计算”按钮(名为bt)的单击事件代码,试按以下要求完成设计。按照以下窗体功能,补充事件代码设计。窗体功
下列关于自动宏的叙述中,正确的是
Mostpeoplehavesimilarideasofwhataphysicistlookslike.Morechildrenwillstudyscienceifitbecomesmoreattractive.
最新回复
(
0
)