首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #inc1ude <iostream> using namespace std; class Base { prVate: Void mnl()const{cout<<"fun1";}
有如下程序: #inc1ude <iostream> using namespace std; class Base { prVate: Void mnl()const{cout<<"fun1";}
admin
2020-04-07
20
问题
有如下程序:
#inc1ude <iostream>
using namespace std;
class Base
{
prVate:
Void mnl()const{cout<<"fun1";}
proteCted:
Void fun2()const{cout<<”mn2¨;}
public:
Void fun3()const{cout<<"fun3";}
};
class DeriVed:prOteCted BaSe
{
public:
Void fun4()const{cout<<"fIun4";}
};
int main()
{
DeriVed obj;
obj.fun1(); //①
obj.fun2(); //②
obj.fun3(); //③
obj.fun4(); //④
reurn O:
}
其中有语法错误的语句是( )。
选项
A、①②③④
B、①②③
C、②③④
D、①④
答案
B
解析
此题考查的是保护继承。因为Derived以protected方式继承了Base类,所以父类Base中的公有成员和保护成员均成了Derived类的保护成员,而Base类的私有成员Derived类不可访问。所以,主函数中通过Derived类的对象只能够访问到Derived类的公有成员。
转载请注明原文地址:https://kaotiyun.com/show/KV8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
定义如下变量:charone_char;,则语句cout<<one_char;显示结果相当于C语言中的()语句。
有以下程序#include<iostream>usingnamespacestd;inta;intfun();intmain(){externinta;intb;
下列实现C语言语句printf("Hello!")的相同功能的语句是( )。
通常拷贝构造函数的参数是
______是数据库设计的核心。
数据的逻辑结构在计算机存储器内的表示,称为数据的【】。
已知类A有公用数据成员a,并重载了=运算符,且有A obj2;const A * ptr= new A;则下列语句错误的是
C++在重载运算符中,如用成员函数重载一元运算符参数表中需要【】个参数,如用友元函数重载一元运算符参数表中需要【】个参数。
请按下面注释的提示,将类B的构造函数定义补充完整。classA{inta;public:A{intaa=0)(a=aa;}}
软件开发软件生命周期分为三个时期共八个阶段:软件定义期(问题定义、可行性研究和需求分析阶段)、软件开发期(系统设计、详细设计、编码和测试阶段)、软件维护期(即运行维护阶段)。
随机试题
当桥梁主塔(墩)塔身高于()m时,应在其顶端装设防撞信号灯。
他律性
根据《物权法》的规定,按份共有人转让其共有财产时,其他共有人在同等条件下有()
选择性α2受体阻断药是
土地登记权属审核的应达标准不包括()。
建设项目管理的工作内容包括项目策划和(。)。
根据《招标投标法实施条例》,对于应当公开招标的施工招标项目可以进行邀请招标的是()。
杜邦分析体系的核心指标是()。
Mycorrhizalfungiinfectmoreplantsthandoanyotherfungiandarenecessaryformanyplantstothrive,buttheyhaveescaped
HitlerandhismenhadtheirhatredtowardsJewsandcolorpeople.Oursocietyisriddledwithsuchhatredbased【S1】_
最新回复
(
0
)