首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Base { private: void fun1 () const{cout
有如下程序: #include using namespace std; class Base { private: void fun1 () const{cout
admin
2016-11-25
22
问题
有如下程序:
#include
using namespace std;
class Base
{
private:
void fun1 () const{cout<<"funl";)
protected:
void fun20 const{cout<<"fun2";}
public:
void fun30 const{cout<<"fun3";)
);
class Derived:protected Base
{
public:
void fun40 const{cout<<"fun4";)
);
int main()
{
Derived obj;
obj.fun10; //①
obj.fun20; //②
obj.fun30; //③
obj.fun40; //④
retum 0:
}
其中有语法错误的语句是( )。
选项
A、①②③④
B、①②③
C、②③④
D、①④
答案
B
解析
此题考查的是保护继承。因为Derived以protected方式继承了Base类,所以父类Base中的公有成员和保护成员均成了Derived类的保护成员,而Base类的私有成员Derived类不可访问。所以,主函数中通过Derived类的对象只能够访问到Derived类的公有成员。
转载请注明原文地址:https://kaotiyun.com/show/uEAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
若有以下程序:#include<iostream>usingnamespacestd;voidsub(intx,inty,int*2){*z=y+x;}intmain(){i
下列叙述中正确的是
内联函数是通过【】来实现的,因此内联函数是真正的函数。
在面向对象方法中,一个对象请求另一对象为其服务的方式是通过发送()。
以下程序的功能是输出1至100之间每位数的乘积大于每位数的和的数,例如对于数字12,有1*2<1+2,故不输出该数;对于27,有2*7>2+7,故输出该数。请填空。#include<iostream.h>voidmain
下面关于虚函数的描述,错误的是
在关系模型中,把数据看成一个二维表,每一个二维表称为一个【】。
实体是信息世界中广泛使用的一个术语,它用于表示
下面是复数类complex的定义,其中作为友元函数重载的运算符“--”的功能是将参数对象的实部减1,然后返回对该对象的引用;请补充完整。classcomplex{private:intreal;iht
下列叙述中正确的是()。
随机试题
Scientistshadtofindoutmanythings【C1】______theycouldlandmen【C2】______themoon.Theyneededmore【C3】______aboutspacecon
被评估债券为2010年发行,面值100元,年利率8%,3年期。2012年评估时,债券市场上同种同期债券,面值100元的交易价为110元,该债券的评估值最接近于()元。
在制定资产评估时间进度安排时不需要()。
下列关于剩余股利分配政策的表述中,不正确的有()。
下列债券中,被称为“金边债券”的是()。
在职业活动中,践行“合作”规范的具体要求包括()
()学习和教学观深刻影响了世界范围内的教育改革,与程序教学运动、学科结构运动合称为20世纪三大教育运动。
以下因素影响龈下菌斑的细菌组成,除了()。
根据国际费雪效应,()。
Now,asoururbanareas(sinkeverdeeper)intodrug-producedcrime,death(from)theillicituseofunregulatedanddangerousd
最新回复
(
0
)