首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
22
问题
有如下类定义:
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://kaotiyun.com/show/jYAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
关于常成员函数,下列说法中错误的是
下列程序的运行结果为______。#include<iostream.h>classmyclass{private:inta,b,c;public:voidfun()
软件生命周期分为软件定义期、软件开发期和软件维护期,详细设计属于______中的一个阶段。
设有定义:classC{public:intValUe;};intX,*p;则以下引用形式中,正确的是()。
类模板template<classT>classx{…},其中友元函数f对特定类型T(如int),使函数f(x<int>)成为x<int>模板类的友元,则其说明为()。
队列是限定在表的一端进行插入和在另一端进行删除操作的线性表。允许插入的一端称作______。
深度为6的满二叉树中,度为2的结点个数为()。
符合结构化原则的三种基本控制结构是:选择结构、循环结构和______。
下列关于栈的叙述中,正确的选项是()
按照标识符的要求,下列选项中,()符号不能组成标识符。
随机试题
心悸而烦、善惊梦多、食少泛恶、舌苔黄腻、脉滑数者,宜选用何方()(1996年第58题)
油藏动态分析必须以单井分析为单元,以油砂体为基础,分析油层内部的变化,搞清各类油层的开发状况及其动态变化规律,从而为改善油田的开发效果服务。()
慢性萎缩性胃炎临床表现可见
下列说法错误的是
患者,男,26岁。心悸,气促1年。查体:两颊暗红,颈静脉明显怒张,下肢浮肿,心浊音界向左扩大,心尖区可闻及舒张期隆隆样杂音,肝右肋下4cm,质软,有压痛,肝颈静脉回流征阳性。应首先考虑的是( )。
对经营性存款人违反规定不及时撤销银行结算账户的法律责任是( )。
胡锦涛同志在十八大报告中指出:扎实推进社会主义文化强国建设,建设社会主义文化强国,关键是增强全民族文化创造活力。加强社会主义文化建设的内容包括:
甲与同村的五名选民同时在外打工,不能回村参加乡人大代表的选举。甲的下列做法,符合法律规定的是()
论证有效性分析:分析下述论证中存在的缺陷和漏洞,选择若干要点,写一篇600字左右的文章,对该论证的有效性进行分析和评论。(论证有效性分析的一般要点是:概念特别是核心概念的界定和使用上是否准确并前后一致,有无各种明显的逻辑错误,论证的论据是否支持结论,论据成
Lookatthenotesbelow.Someinformationismissing.YouwillhearareportonE-money.Foreachquestion(16-22),fillinthem
最新回复
(
0
)