首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #inclulde using namespace std; class Base { private: void funl() const{tout
有如下程序: #inclulde using namespace std; class Base { private: void funl() const{tout
admin
2020-04-07
29
问题
有如下程序:
#inclulde
using namespace std;
class Base
{
private:
void funl() const{tout<<"fun1";}
protected:
void fun2() const{cout<<"fun2";}
public:
void fun30 const{cout<<"fun3";}
};
class Derived:protected Base
{
public:
void fun4() const{tout<<"fun4";}
};
int main()
{
Derived obj;
obj.fun1(); ∥①
obj.tim2(); ∥②
obj.fun3(); ∥③
obj.fun40; ∥④
return 0;
}
其中有语法错误的语句是( )。
选项
A、①②⑧④
B、①②③
C、②③④
D、①④
答案
B
解析
此题考查的是保护继承。因为Derived以protected方式继承了Base类,所以父类Base中的公有成员和保护成员均成了Derived类的保护成员,而Base类的私有成员Derived类不可访问。所以,主函数中通过Derived类的对象只能够访问到Derived类的公有成员。
转载请注明原文地址:https://kaotiyun.com/show/z38p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列叙述中正确的是
以下程序的执行结果是【】。#include<iostream.h>template<classT>classSample{Tn;public:Sample(Ti){n=i;)voidoperator();v
有如下类的定义。横线处的语句是()。classMyClass{public:MyClass(inta=0,intb=0){X=a:Y=b:}
线性表的顺序存储结构和线性表的链式存储结构分别是
有如下类定义,请将Sample类的拷贝构造函数补充完整。classSample{public:Sample(){)~Sample(){if(p)deletep;)Sample(con
下列运算符中,不能重载的是
已知intDBL(intn){returnn+n;}和longDBL(longn){returnn+n)是一个函数模板的两个实例,则该函数模板的定义是【】。
有如下函数模板声明:template<typenameT>TMax(Ta,Tb){return(a>=b)?a:b;}下列对函数模板Max()的调用中错误的是
A、 B、 C、 D、 B在引用函数模板时,如果没在函数名和参数之间加上类型参数,就默认表示参数类型严格按照模板定义的类型匹配;如果在函数名和参数之间加上了类型参数,则对实参自动进行类型转换。
以下选项中,()是合法的字符常量。
随机试题
下列能够用于错账更正的工具是()。
某同学大学毕业已有机会就业,可又想考硕士研究生,举棋不定,难以决断,心情焦虑。上述行为属于哪种冲突
十万级洁净区的指标为
信用证结算是当前国际贸易的主要结算方式,下列关于信用证结算特点表述错误的是()。
家庭教养方式对儿童有重要影响,该案例中反映的家庭家养方式倾向于()。
某商品进价240元,8折销售后还可获利40元,则原销售价的加价率为()。
人们在思维活动中使用的言语是()。
WorkingEnvironmentYourcompanyhasmadeadiscussionaboutcreatingaharmoniousatmosphere.Youhavebeenaskedtomakerecom
Publictransit.InNorthAmerica,publictransportationhasbeenthemajorcasualtyofthecommitmenttotheautomobile.Ridersh
Thepopularityofcross-borderonlineshoppingisgrowinginChina.Fromtheexcerpts,youcanfindthatcross-borderonlinesho
最新回复
(
0
)