首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class Test { public: Test(){a=0;c=0;} ∥① int f(int a) bonst{this->a=a;} //② static int g ()
有如下类定义: class Test { public: Test(){a=0;c=0;} ∥① int f(int a) bonst{this->a=a;} //② static int g ()
admin
2019-04-01
21
问题
有如下类定义:
class Test
{
public:
Test(){a=0;c=0;} ∥①
int f(int a) bonst{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
解析
此题考查的是类的定义。一个类的长数据成员的初始化只能在成员初始化列表中进行,故选项A错误;常成员函数不能更新对象的数据成员,故选项B错误;静态成员函数可以直接访问类中说明的静态成员,但不能直接访问类中说明的非静态成员,故选项C错误。
转载请注明原文地址:https://jikaoti.com/ti/Wpt0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下说法中错误的是
软件开发的结构化生命周期方法将软件生命周期划分成
所有在函数中定义的变量,连同形式参数,都属于
若有说明语句:chara[]="Itismine";char*p="Itismine";则以下不正确的叙述是
下面对静态数据成员的描述中,正确的是
下面关于数组的初始化正确的是
有如下程序:#include<iostream)usingnamespacestd;intmain(){int*p;*p=9;cout<<“Thevalueatp:”<<*p;re
下列叙述中正确的是()。
下列选项中不属于结构化程序设计原则的是
随机试题
什么叫样冲?有什么作用?
下列作品中,明确反对“万般皆下品,惟有读书高”传统观念的是()
二手房客户信息管理的内容不包括()。
按转动铰链和转轴位置的不同,房屋的横式旋转窗的种类主要有()。
我国及时总结证券市场发展的经验教训,确立了指导证券市场健康发展的()的“八字方针”,初步形成了有中国特色的集中统一的监管体系。
股票发行上市后,其市场价格的高低主要是由预期股利和当时的市场利率决定的。()
社区居委会的基本属性是()。
环境保护、开发新能源是未来能源利用的主旋律。下列做法中最有利于环境保护的是()。
在一组竞争性方案中,运用过半数原则先对两个方案进行两两成对比较,然后将剩余的方案与其他方案依次比较,这一原则属于()。
Inasweepingoverallinspectionofits$21billionMedicaidprogram,theFloridaLegislatureapprovedabilltoshiftnearlyth
最新回复
(
0
)