首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class AA { int k; protected: int n; void setK(int k){
有如下程序: #include<iostream> using namespace std; class AA { int k; protected: int n; void setK(int k){
admin
2021-05-06
17
问题
有如下程序:
#include<iostream>
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
解析
k是private,对派生类BB不可见,3错误;n、setK是protected,在派生类BB中是protected,对派生类BB的对象不可见,1,4错误;setN是public,在派生类BB中是public,对派生类BB的对象可见,2正确;故本题答案为B选项。
转载请注明原文地址:https://kaotiyun.com/show/8Hfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下类定义classAnimal{public:virtualvoidName0=0;};classKoala:publicAnimal{public:voidName(){/*函数体略*/}};关于上述类定义,下列描述中错
有如下语句序列:intx=100,&r==x;cout
下列情况中,不会调用拷贝构造函数的是()。
下列类模板的定义中语法格式错误的是()。
有如下两个类定义:classXX{private:doublex1;protected:doublex2;public:doublex3;};classYY:protectedXX{private:doubley1
下列数据结构中,能用二分法进行查找的是()。
下列关于栈的叙述正确的是()。
下列叙述中,正确的是
公司中有多个部门和多名职员,每个职员只能属于一个部门,一个部门可以有多名职员。则实体部门和职员间的联系是
数据库设计过程不包括()。
随机试题
腰椎间盘突出症和腰椎椎管狭窄症的主要鉴别点为
骨折移位的发生因素有()。
酶介质交叉配血试验中酶的作用,不包括
目前治疗中度原发性甲状腺功能亢进的常用而有效的疗法是
A.急性多发性神经根神经炎B.急性脊髓炎C.周期性瘫痪D.重症肌无力E.帕金森病
治疗支原体肺炎热闭心神证,应首选()
呋塞米可引起氨甲苯酸过量可引起
某代表团有756名成员.现要对A、B两议案分别进行表决,且他们只能投赞成票或反对票。已知赞成A议案的有476人,赞成B议案的有294人,对A、B两议案都反对的有169人。则赞成A议案且反对B议案的有()。
1840年至1919年的80年问,中国人民为反对外来侵略进行了英勇斗争,但都失败了,从中国内部因素来分析,其根本原因是
Tomanyvisitorstoacountrytheword"city"meansthecapitalcity.Andthatinitsturnmeanswhatwouldbetakeninbyagro
最新回复
(
0
)