首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class AA { int k; protected: int n; void setK(int k) { this->k=k; } public: void setN(int n
有如下程序: #include using namespace std; class AA { int k; protected: int n; void setK(int k) { this->k=k; } public: void setN(int n
admin
2021-02-22
21
问题
有如下程序:
#include
using namespace std;
class AA {
int k;
protected:
int n;
void setK(int k) { this->k=k; }
public:
void setN(int n) { this->n=n; }
};
class BB: public AA { /*类体略*/ };
int main()
{
BB x;
x.n=1; //1
x.setN(2); //2
x.k=3; //3
x.setK(4); //4
return 0;
}
在标注号码的四条语句中正确的是( )。
选项
A、1
B、2
C、3
D、4
答案
B
解析
本题考查公用继承对基类成员的访问属性。在公用继承中,基类的公用成员和保护成员在派生类中保持原有访问属性,其私有成员仍为基类私有。所以本题中n、k和setK变为了派生类的保护成员,不能直接使用,即1、3、4错误,所以B选项正确。
转载请注明原文地址:https://kaotiyun.com/show/Cbfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
面向对象方法中,继承是指
下列与队列结构有关联的是
下面不能作为结构化方法软件需求分析工具的是
使用地址作为实参传给形参,下列说法正确的是()。
计算数列第n项的函数定义如下:intfa(intn){if(n==1)return1;elsereturn3*fa(n一1)+2;若执行函数调用表达式fa(4)时,返回的函数值为()。
有如下类和对象的定义:classConstants{public:staticdoublegetPI(){return3.1416;}};Constantsconstants;下列各组语
设有表示学生选课的三张表,学生S(学号,姓名,性别,年龄,身份证号),课程C(课号,课名),选课SC(学号,课号,成绩),则表SC的关键字(键或码)为()。
语句int*p=&k;定义了指针p,与这个语句等效的语句序列是()。
线性表的长度为n。在最坏情况下,比较次数为n一1的算法是
当循环队列非空且队尾指针等于队头指针时,说明循环队列己满,不能进行入队运算。这种情况称为()。
随机试题
PASSAGEONE(1)Iknownowthatthemanwhosatwithmeontheoldwoodenstairsthathotsummernightoverthirty-fiveyear
在某研究所里,所有的工程师都是工会会员,有的管理人员是硕士,有的工程师是硕士,所有工会会员都办了信用卡,没有管理人员办信用卡。如果以上所述为真,则以下哪项必假?
患者女,19岁,颏部发育差,唇前突闭合不全,覆盖10mm,磨牙完全远中关系,前牙深覆牙合,ANB10°,上前牙前突,牙列无拥挤4个第三磨牙牙胚不存在
以吐温-80作增溶剂的液体制剂,最佳选用的防腐剂是
地下燃气管道埋设的最小覆土厚度(路面至管顶)应符合下列哪些要求()。
乙公司是一家图书销售企业,目前在全国拥有200多家图书销售实体店。随着网络电商参与图书经营,使销售图书的实体店受到严重冲击。为此,乙公司决定也在网上设立虚拟店铺,专门对图书进行销售。但因乙公司未有过进行信息技术运营的资源和经验,因此,乙公司将网络销售的相关
环境科学家:在过去的10年中,政府对保护湿地的投资确实增加了6倍,而同时需要这样保护的土地面积只增加了2倍(尽管这些区域在10年前就已经很大了)。即使把通货膨胀考虑进去,今天的资金数额也至少是10年前的3倍。虽然如此,目前政府对保护湿地的投资仍是不够的,政
按照唐朝的法律规定,下列选项中,适用自首减免刑罚原由的犯罪包括()。
为防止重大灾难毁灭重要数据,大型数据中心应实行(67)制度。
以下叙述中错误的是()。
最新回复
(
0
)