首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class Base { private: void fun1() const{cout<<’’fun1’’;}
有如下程序: #include<iostream> using namespace std; class Base { private: void fun1() const{cout<<’’fun1’’;}
admin
2019-06-12
64
问题
有如下程序:
#include<iostream>
using namespace std;
class Base
{
private:
void fun1() const{cout<<’’fun1’’;}
protected:
void fun2() const{cout<<’’fun2’’;}
public:
void fun3() const{cout<<’’fun3’’;}
};
class Derived:protected Base
{
public:
void fun4()const{cout<<’’fun4";}
};
int main()
{
Derived obj;
obj.funl(); //①
obj.fura(); //②
obj.fun3(); //③
obj.fun4(); //④
return 0;
}
其中有语法错误的语句是( )。
选项
A、①②③④
B、①②⑧
C、②③④
D、①④
答案
B
解析
此题考查的是保护继承。因为Derived以protected方式继承了Base类,所以父类Base中的公有成员和保护成员均成了Derived类的保护成员,而Base类的私有成员Derived类不可访问。所以,主函数中通过Derived类的对象只能够访问到Derived类的公有成员。
转载请注明原文地址:https://kaotiyun.com/show/mH8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;classA{public:A(){cout
为了表明一个函数不带返回值,应在定义函数时指定该函数类型为【 】。
有以下程序:#include<iostream>usingnamespacestd;voidt(intx,inty,intcp,intdp){cp=x*x+y+y;d
__________是一种特殊的成员函数,它主要用来为对象分配内存空间,对类的数据成员进行初始化并执行对象的其他内部管理操作。
当执以下程序段时,循环体将执行(),main(){inty=1;do{y--;}while(--y):}
面向对象程序设计思想的主要特征中不包括
若有以下定义和语句,则对w数组元素的非法引用是______。intw[2][4],(*pw)[4];pw=w;
有下列程序:#include<iosteram.h>usingnamespacestd;classStack{public:Stack(unsignedn=10)
随机试题
使用表设计器来定义表的字段时,以下()可以不设置内容。
维生素B12缺乏可导致【】
肾病综合征的一般治疗正确的是
药品监督管理部门在进行监督检查时,应
在建设项目的投资机会研究阶段,误差率应在( )以内。
关键线路具有()等特征。
下列行为中不属于经营者滥用市场支配地位行为的是()。
列举十种校内美术课程资源。
Generallyspeaking,aBritishiswidelyregardedasaquiet,shyandconservativepersonwhois【1】onlyamongthosewithwhomhe
A、Torunthecommitteehisway.B、Tomakehimselfthecommitteechairman.C、Todowhateverthecommitteeaskshimto.D、Tomake
最新回复
(
0
)