首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: c1ass Test { public: Test(){a=0;c=0;} //① int f(int a)const{this—>a=a;} //② static int g()
有如下类定义: c1ass Test { public: Test(){a=0;c=0;} //① int f(int a)const{this—>a=a;} //② static int g()
admin
2020-04-07
23
问题
有如下类定义:
c1ass 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
解析
此题考查的是类的定义。一个类的长数据成员的初始化只能在成员初始化列表中进行,故选项A错误;常成员函数不能更新对象的数据成员,故选项B错误:静态成员函数可以直接访问类中说明的静态成员,但不能直接访问类中说明的非静态成员,故选项C错误。
转载请注明原文地址:https://kaotiyun.com/show/aC8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下4个选项中,属于浮点数常量的是()。
若运行时给变量x输入12,则以下程序的运行结果是#include<iostream.h>voidmain(){intx,y;cin>>x;y=X>12?x+10:x-12;cout
以下程序的执行结果是______。#include<iostream.h>classA{inta;public:voidseta(intx
若有以下程序:#include<iostream>usingnamespacesstd;classA{public:A(){}A(inti){
有如下类定义,请将Sample类的拷贝构造函数补充完整。classSample{public:Sample(){)~Sample(){if(p)deletep;)Sample(con
已知数据表A中每个元素距其最终位置不远,为节省时间,应采用的算法是()。
下列运算符中,不能重载的是
下列选项中,不是C++关键字的是()。A)classB)functionC)friendD)virtual
在深度为5的完全二叉树中,叶子结点的个数最多为【 】。
数据库设计分为需求分析阶段、______阶段、逻辑设计阶段、物理设计阶段、数据库实施阶段、数据库运行和维护阶段。
随机试题
汽车_______是企业宝贵的营销资源。
肥料树可以形成生物自肥作用,下列树种属于肥料树的是()。
全面质量管理
甲乙两国是温室气体的排放大国,甲国为发达国家,乙国为发展中国家。根据国际环境法原则和规则,下列哪一选项是正确的?
资产负债表的作用有()。
三维目标在美术课程中的具体要求是什么?
在大型复杂IT项目管理中,为了提高项目之间的协作效率,通常应首先(51)。
下列关于虚拟存储器的叙述中,哪些是正确的?()
计算机的系统总线是计算机各部件间传递信息的公共通道,它分为()。
"RisingSeaLevels"Perhapsthemostpervasiveclimaticeffectofglobalwarmingisrapidescalationoficemelt.MountKili
最新回复
(
0
)