首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: class Base{ public: int data; }; class Derivedl:public Base{}; class Derived2:protected Base{};
有如下程序: class Base{ public: int data; }; class Derivedl:public Base{}; class Derived2:protected Base{};
admin
2020-04-07
56
问题
有如下程序:
class Base{
public:
int data;
};
class Derivedl:public Base{};
class Derived2:protected Base{};
int main(){
Derivedl d1;
Derived2 d2;
d1.data=0; ∥①
d2.data=0; ∥②
return 0;
}
下列关于程序编译结果的描述中,正确的是( )。
选项
A、①②皆无编译错误
B、①有编泽错误,②无编译错误
C、①无编译错误,②有编译错误
D、①②皆有编译错误
答案
C
解析
保护继承的类Dervied2不能访问基类Base中的公共数据成员data。
转载请注明原文地址:https://kaotiyun.com/show/LC8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下面程序的运行结果是#include<iostream.h>intfun(inta[],intn){intresult=1;for(inti=1;i<n;i++)
若有定义“intx=10,y=3,z;”,则语句“cout<<(z=(x%y,x/Y));”的输出结果是______。
参照函数模板的写法,完成非模板函数的定义,语句为【 】。#include<iostream,h>#include<string.h>template<classT>
C++语句constchar*constp="hello";,所定义的指针p和它所指的内容都不能被【】。
下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。#defineMAXSIZE100template<classT>classStack{Ts[MAXSIZE];
执行语句序列:intx=10,&r=x;cout
下面程序的输出结果是______。#include<iostream>usingnamespacestd;intx;voidfunA(int&,int);voidfunB(int,int&);int
用树形结构来表示实体之间联系的模型称为()。
随机试题
患者,男,50岁,进行性吞咽困难3个月,现能进流质饮食。检查:锁骨上未触及肿大的淋巴结。对于该患者,拟行全麻下食管癌根治术,下列关于手术前后的护理的描述错误的是
舌黏膜中的味觉感受器是
A.法莫替丁B.多潘立酮C.氯苯那敏D.奥美拉唑E.莫沙必利属于选择性5-HT4受体激动剂的是()
企业文化观念对于安全管理没有影响。
基金单位总数不固定,总金额不封顶且可以连续发行,一般投资者可以随时进入或退出的基金为()。
资本市场具有()的特点。
下列Cisco路由器进入vty配置模式后的命令提示符,正确的是()。
A、Buyapresent.B、Buyanewdress.C、Preparesomefood.D、Gathersomemoney.B
A、Todescribechildren’sthinking.B、Toanswersomequestionschildrenhave.C、Tostresstheimportanceofcommunication.D、Toa
Itisnosecretthathealthcarehasbecomeincreasinglyunaffordableasthecostofmedicaltreatmentsandinsurancepremiums(保
最新回复
(
0
)