首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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){Tes
有如下类定义: 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){Tes
admin
2017-07-28
15
问题
有如下类定义:
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
解析
只能通过构造函数的参数初始化列表对常数据成员进行初始化,本题中常数据成员为c。①通过默认构造函数初始化c,所以不正确。常成员函数只能引用本类中数据成员,而不能修改它,所以②不正确。静态成员函数由于没有this指针,所以不能访问本类中的非静态成员,所以③错误。
转载请注明原文地址:https://jikaoti.com/ti/9mt0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下面程序的输出结果是()。#include<iostream>usingnamespaceStd;intmain(){intx[6]={1,3,5,7,9,11},*k,**s;
for(intx=0,y=0;!x&&y<=5;y++)语句执行循环的次数是()。
下列程序的输出结果是【 】。#include<iostream.h>template<classT>Tmax(Tx[],intn){inti;Tmaxv=x[0];f
依照某种数据模型组织起来并存放二级存储器中的数据集合是指( )。
以下不能够读入空格字符的语句是
语句cout<<(a=2)&&(b=-2);的输出结果是
将下列程序写成三目运算表达式是()。if(x<y)min=x;elsemin=y;
C++语言中的基本符号可以分为_______、_________、________三类。
随机试题
A.黄连温胆汤B.半夏秫米汤C.黄连阿胶汤D.天王补心丹E.交泰丸治疗痰热扰心证之不寐者,宜选用
对于企业投资建设的无形产品项目,必要时应专门进行经济分析,主要理由是()。
工程项目目标系统表现为一个()结构。
如图,游客从某旅游景区的景点A处下山至C处有两种路径。一种是从A沿直线步行到C,另一种是先从A沿索道乘缆车到B,然后从B沿直线步行到C.现有甲、乙两位游客从A处下山,甲沿AC匀速步行,速度为50m/min.在甲出发2min后,乙从A乘缆车到B,在B处停留1
Ifsomeonejuststudiesafewrecentcorporaterecruitmentadvertisements,therewillbeatleastonethingheorshewillfind
现在市面上充斥着《成功的十大要素》之类的书。出版商在推销此类书时声称,这些书将能切实地帮助读者成为卓越的成功者。事实上,几乎每个人都知道,卓越的成功注定只属于少数人,人们不可能通过书本都成为这少数人群中的一个。基于这一点,出版商故意所做的上述夸张乃至虚假的
描述数据通信的基本技术参数是数据传输速率与【 】。
Supposingtheydidnotcomeback,what______youdo?
Whyaresomanypeopleunhappyintheirjobs?Herearetwoprimaryreasons.First,somepeopleareconvincedthatearningalivi
1月中旬,某食糖购销企业与一个食品厂签订购销合同,按照当时该地的现货价格3600元/吨在2个月后向该食品厂交付2000吨白糖。该食糖购销企业经过市场调研,认为白糖价格可能会上涨。为了避免2个月后为了履行购销合同采购白糖的成本上升,该企业买入5月份交割的
最新回复
(
0
)