首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class Test { public: Test(){a=0;c=0;}//① int f(int a)const{this->a=a;}//② static int g(){return
有如下类定义: class Test { public: Test(){a=0;c=0;}//① int f(int a)const{this->a=a;}//② static int g(){return
admin
2020-10-21
23
问题
有如下类定义:
class Test
{
public:
Test(){a=0;c=0;}//①
int f(int a)const{this->a=a;}//②
static int g(){return a;}//③
void h(int b){Test::b=b;};//④
private:
int a;
static int b;
const int C;
};
int Test::b=0;
在标注号码的行中,能被正确编译的是( )。
选项
A、①
B、②
C、③
D、④
答案
D
解析
只能通过构造函数的参数初始化列表对常数据成员进行初始化,本题中常数据成员为e。①通过默认构造函数初始化C,所以不正确。常成员函数只能引用本类中数据成员,而不能修改它,所以②不正确。静态成员函数由于没有this指针,所以不能访问本类中的非静态成员,所以③错误。
转载请注明原文地址:https://jikaoti.com/ti/D2l0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,其中在编辑窗口内显示的主程序文件中定义有类ABC和主函数main。程序文本中位于每行“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结
请使用VC6或使用【答题】菜单打开考生目录proj3下的工程文件proj3,其中定义了用于表示特定数制的数的模板类Number和表示一天中的时间的类TimeOfDay;程序应当显示:01:02:03.00406:04:06.021
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,该工程中包含程序文件main.cpp,其中有类Mammal(“哺乳动物”)、类Elephan(“大象”)、类Nouse(“老鼠”)的定义和主函数main的定义。请在横线处填写适当的代
请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Name:SmithAge:21ID:99999C
请使用VC6或使用【答题】菜单打开考生目录proj3下的工程文件proj3,此工程包含一个源程序文件proj3.cpp,其功能是从文本文件in.dat中读取全部整数,将整数序列存放到intArray类的对象myArray中,然后对整数序列按非递减排序,最后
待排序的关键码序列为(15,20,9,30,67,65,45,90),要按关键码值递增的顺序排序,采取简单选择排序法,第一趟排序后关键码15被放到第()个位置。
若MyTemp是一个只有一个虚拟类型参数的类模板,且有如下语句序列MyTemp<double>p2;MyTemp<long>p3[2];编译系统在处理上面的语句序列时,所生成的模板MyTemp的实例的个数是()。
下列关于运算符重载的叙述中,错误的是()。
在深度为7的满二叉树中,叶子结点的个数为()。
学院的每名教师只能属于一个系,则实体系和实体教师间的联系是
随机试题
下列药组中,不宜合用的有()(2008年第144题)
小余自幼跟爷爷奶奶一起生活,备受宠爱,是个十分调皮和任性的孩子。上小学时,小余才回到父母身边,和父母比较生疏,学习表现不佳,时常被父亲呵斥;小余也因此变得非常焦虑,上课注意力不集中,有时作业也完成不了,老师也反映小余在学校不爱说话,课间活动时常常一个人躲在
爆炸就是发生的激烈的化学反应。()
如果函数f(x)的定义域为[1,2],则函数f(1一lnx)的定义域为()?
经济订货模型是建立在一系列严格假设基础之上的,这些假设包括()。
A公司是一家有限责任公司,共有15位股东,其中股东甲持有20%有表决权的股权;股东乙持有15%有表决权的股权;股东丙持有10%有表决权的股权。A公司由于经营不善,连年亏损,净资产已经降至人民币300万元,包括董事长在内的几位董事陆续提出辞职。股东
2014年8月31日,十二届全国人大常委会第十次会议表决通过了关于设立烈士纪念日的决定,以法律形式将9月30日设立为烈士纪念日,并规定每年纪念日当天国家举行纪念烈士活动。选择将9月30日设立为烈士纪念日最有可能是因为()。
根据图1、图2回答问题经初步核算,全年生产总值为2710.28亿元,按可比价格计算,比上年增长13.7%,这一增速为1985年以来最快增长水平。三次产业实现全面增长,其中,第一产业增加值为455.67亿
只要天上有太阳并且气温在零度以下,街上总有很多人穿皮夹克。只要天下着雨并且气温在零度以上,街上总有人穿雨衣。有时,天上有太阳但却同时下着雨。如果上述断定为真,那么以下哪项一定为真?
A、Moredetailedlabeling.B、Simplelabeling.C、Preciselabeling.D、Basiclabeling.A文章最后提到,如今食品标签必须向消费者提供更为详细的信息,答案为A。
最新回复
(
0
)