首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
27
问题
有如下程序:
#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;classTest{public:Test(){n+=2;}~Test(){n-=3;)staticimge
为了表明一个函数不带返回值,应在定义函数时指定该函数类型为【 】。
有以下程序:#include<iostream>#include<string>usingnameSpacestd;classperson{intage;
若有以下定义和语句,则对w数组元素的非法引用是______。intw[2][4],(*pw)[4];pw=w;
要定义数组A,使得其中每个元素的数据依次为:3、9、4、8、0、0、0,错误的定义语句是
大多数C++程序都要包含______头文件。该文件中包含了所有输入/输出流操作所需要的基本信息。
软件结构是以______为基础而组成的一种控制层次结构。
队列是限定在表的一端进行插入和在另一端进行删除操作的线性表。允许插入的一端称作______。
随机试题
关于麻醉的选择,错误的是
甲公司与乙公司约定,由甲公司向乙公司交付1吨药材,乙公司付款100万元。乙公司将药材转卖给丙公司,并约定由甲公司向丙公司交付,丙公司收货后3日内应向乙支付价款120万元。张某以自有汽车为乙公司的债权提供抵押担保,未办理抵押登记。抵押合同约定:“在
在确定建设工程投资目标时,若考虑时间和外部条件的变化进行调整,可以采用()进行预测分析。
人体基本组织有()。
人民警察离休、退休的,其警衔()。
下列我国古代杰出医学家中,被后人誉为“脉学之宗”的是:
下列关于INSERT语句功能的描述中,正确的是
Childrenloamalmostnothingfromtelevision,andthemoretheywatch,thelesstheyremember.Theyregardtelevisionpurely【71】
Ofalltheareasoflearningthemostimportantisthedevelopmentofattitudes.Emotionalreactionsaswellaslogicalthought
TheAbortionClinicShootings:Why?A)Asthenationheardwithsorrowthenewsofthedeplorableshootingspreeatabortionfaci
最新回复
(
0
)