首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class Test { public: Test(){a=0;c=0;} //① int flint a)const{this->a=a;} //② static int g (
有如下类定义: class Test { public: Test(){a=0;c=0;} //① int flint a)const{this->a=a;} //② static int g (
admin
2018-08-13
30
问题
有如下类定义:
class Test
{
public:
Test(){a=0;c=0;} //①
int flint 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;
};
intTest::b=0;
在标注号码的行中,能被正确编译的是( )。
选项
A、①
B、②
C、③
D、④
答案
D
解析
此题考查的是类的定义。一个类的长数据成员的初始化只能在成员初始化列表中进行,故选项A错误;常成员函数不能更新对象的数据成员,故选项B错误;静态成员函数可以直接访问类中说明的静态成员,但不能直接访问类中说明的非静态成员,故选项C错误。
转载请注明原文地址:https://kaotiyun.com/show/pAAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有下列程序:#include<iostream>usingnamespacestd;classTestClass{private:intx,y;public:
有下列程序:#include<iostream>usingnamespacestd;intmain(){voidfunction(doubleval);dou
友元类的所有成员函数都是另一个类的______。
将x=y*z中的“+”用成员函数重载,“*”用友元函数重载应写为______。
设计程序时,应采纳的原则之一是()。
数据结构分为线性结构和非线性结构,带链的队列属于______。
通过使用new和delete两个运算符进行的分配为______存储分配。
下列对派生类的表述中,错误的是()。
C++语言函数中不能由系统自动生成的是
下列叙述中错误的是()。
随机试题
下列属于机械式挖泥船的是()。
从加强出版工作者职业道德建设的要求来看,某出版社的下列行为中,正确的有()。
旅游消费的学习,意指人们学习正确地使用_______。
在Excel2003中创建数据透视表,要用该表统计基础数据中行的数量,应使用__________函数。()
以下哪些是水火共制的方法
子宫动脉的正常频谱形态(非妊娠期)是:
下列关于期货公司业务的说法,正确的是()。
甲公司于2007年5月就一种新型电池提出了发明专利申请,该申请于2008年12月4日公布。乙公司于2007年9月自行研制了同样的电池,并于同年10月正式批量生产。2009年10月16日,甲公司的申请被公告授予专利权,此时,乙公司仍保持原有的规模生产该种电池
在Excel工作簿中,工作表______。
A—purchaseB—possibleclientsC—quotationD—advertisementE—invoiceF—orderG—st
最新回复
(
0
)