首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Base { private: void funl 0 const{cout
有如下程序: #include using namespace std; class Base { private: void funl 0 const{cout
admin
2019-02-22
16
问题
有如下程序:
#include
using namespace std;
class Base
{
private:
void funl 0 const{cout<<“funl”;)
protected:
void fun2()const{cout<<“fun2”;)
public:
void fun3()const{cout<<“fun3”;)
};
class Derived:protected Base
{
public:
void fun40 const{cout<<“fun4”;)
};
int main()
{
Derived obj;
obj.funl(); ∥①
obj.fun2(); ∥②
obj.fun3(); ∥③
obj.fun4(); ∥④
return ();
)
其中有语法错误的语句是( )。
选项
A、①②③④
B、①②③
C、②③④
D、①④
答案
B
解析
此题考查的是保护继承。因为Derived以protected方式继承了Base类,所以父类Base中的公有成员和保护成员均成了Derived类的保护成员,而Base类的私有成员Derived类不可访问。所以,主函数中通过Derived类的对象只能够访问到Derived类的公有成员。
转载请注明原文地址:https://kaotiyun.com/show/rMAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
对于下面定义的类MyClass,请在函数f()中添加对象成员把n的值修改为50。ClassMyClass{Public:MyClass(intx){n=x;)VoidSetNum(intnl){n=nl;}
有如下程序:#include<iostream>usingnamespacestd;ClassTest{public:Test(){n+=2;}~Test(){n-=3;}sta
有如下函数模板声明:template<typenameT>TMax(Ta,Tb){return(a>=b)?a:b;}下列对函数模板Max()的调用中错误的是()。
在结构化分析方法中,用于描述系统中所用到的全部数据和文件的文档称为______。
假定有下列变量定义:intk=7,x=12;则能使值为0的表达式是
对于类定义classA{public: virtualvoidfunc1(){} voidfunc2(){}};classB:publicA{publi
用树结构表示实体类型及实体间联系的数据模型称为______。
将E-R图转换到关系模式时,实体与联系都可以表示成
在数据库系统中,用户所见的数据模式为
关于关键字class和typename,下列说法中正确的是
随机试题
局麻病人发生晕厥,应迅速将其体位调整为:()
A、牙龈增生覆盖牙冠不超过1/3B、牙龈增生覆盖牙冠的1/3,不超过2/3C、牙龈增生覆盖牙冠的1/2,不超过2/3D、牙龈增生覆盖常超过牙冠的2/3E、牙龈形态基本正常下列疾病牙龈增生的程度增生性龈炎为
土地是一种公共资源,其价格水平必须受到政府管制,不得随意涨价或者降价,因此政府实行土地价格备案制度。()
根据《建设工程安全生产管理条例》,依法批准开工报告的建设工程,建设单位应当自开工报告批准之日起( )内,将保证安全施工的措施报送建设工程所在地的县级以上人民政府建设行政主管部门或者其他有关部门备案。
反映企业在某一特定日期的资产、负债和所有者权益及其相互关系的会计报表是()。
测验项目对所测量属性或品质的区分程度和鉴别能力,称为______。
A、 B、 C、 B
MakingandWritingWordsI.AbriefintroductionA.Makingwordsisconceptuallyanengagingandeffectiveinstructionaltask.
ThefluteisanancientChinesemusicalinstrument,andisalsoakindofwindinstrumentendowedwiththemostdistinctnationa
Forthispart,youareallowed30minutestowriteashortessayentitledWillTelecommutingBecomePopular"]Youshouldwritea
最新回复
(
0
)