首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
设有以下定义和程序: #include class TestClass1 { public: void showl() { cout
设有以下定义和程序: #include class TestClass1 { public: void showl() { cout
admin
2021-05-06
34
问题
设有以下定义和程序:
#include
class TestClass1
{
public:
void showl()
{
cout<<"TestClass1"<
}
};
class TestClass2:TestClass1
{
public:
void show2()
{
cout<<"TestClass2"<
}
};
class TestClass3:protected TestClass2
{
public:
void show30
{
cout<<"TestClass 3"<
}
};
voidmain()
{
TestClass1 obj1;
TestClass2 obj2;
TestClass3 obj3;
}
则以下不合语法的调用语句是( )。
选项
A、obj1.showl();
B、obj2.showl();
C、obj3.showl();
D、obj2.show2();
答案
C
解析
TestClass1为TestClass2的私有基类,所以派生类TestClass2中继承过来的show1()为私有的。TestClass3为TestClass2的受保护派生类。所以TestClass3定义的对象不能访问TestClass中的showl()。
转载请注明原文地址:https://www.kaotiyun.com/show/QHfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下类定义classAnimal{public:virtualvoidName0=0;};classKoala:publicAnimal{public:voidName(){/*函数体略*/}};关于上述类定义,下列描述中错
数据库设计中,用E-R图来描述信息结构但不涉及信息在计算机中的表示,它属于数据库设计的()。
下列关于C++函数的叙述中,正确的是()。
有如下类定义:classMyBase{intk:public:MyBase(intn:0):k(n){)intvalue()const{returnk;}};classMyDeriv
下面属于黑盒测试方法的是()。
有如下程序:#includeusingnamespacestd;intmain(){charstr[100],*p;cout
有如下程序:#includeusingnamespacestd;classAA{public:AA0{cout
数据库DB、数据库系统DBS、数据库管理系统DBMS之间的关系是()。
随机试题
在采用首次适用策略的可变分区存储管理中,某作业完成后要收回其主存空间并修改空闲区表。使空闲区始址不改变,空闲区数也不变的情况是_______。
下列关于个人独资企业法律特征的表述中,正确的是( )。
商业银行贷款,应当实行审贷分离、分级审批的制度。()
民警甲接到王某报警称有人飞车抢夺,于是设卡拦截,因犯罪嫌疑人驾驶摩托车冲卡而逃,甲驾驶警车闯红灯追赶。犯罪嫌疑人逃至一小巷,警车无法驶入,民警甲便使用公民乙的摩托车继续进行追赶,抓获犯罪嫌疑人丙,但不慎将摩托车撞坏。对于犯罪嫌疑人丙委托辩护律师的行为,
OA(OfficeAutomation)
微分方程y’’-y’-6y=(x+1)e-2x的特解形式为().
设f(x)连续,则xf(x-t)dt=_______
Project(69)Management includes the processes required to ensure that the project includes all the work required, and only the wo
设A、B、C是三角形的3条边,则以下表示“任意两边之和大于第三边”的布尔表达式是
Nearlyallsurgicalstuntsstickthemselveswithneedlesand【C1】______instrumentswhileintraining.But【C2】______failtorepo
最新回复
(
0
)