首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class AA{ int k; protected: int n; void setK(int k){this->k=k;}
有如下程序: #include using namespace std; class AA{ int k; protected: int n; void setK(int k){this->k=k;}
admin
2017-12-14
34
问题
有如下程序:
#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{/*类体略*/};
mt mmn()
{
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/mjAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;classMusic{public:voidsetTitle(char*str){strcpy(title,str);}pr
有如下程序:#includedusingnamespacestd;classCD{public:~CD(){cout
有三个关系R、S和T如下:则由关系R和S得到关系T的操作是
有以下程序main(){inti=0,s=0;do{if(i%2){i++;continue;}i++;s+=i;}while(i<7);cout<<s<<
以下程序的输出结果是intf(){staticinti=0;ints=1;s+=i;i++;returns;}main(){
有以下程序段intk=0;while(k=1)k++;while循环执行的次数是
如下程序的输出结果是main(){floatx=2.0,y;if(x<0.0)y=0.0;elseif(x<10.0)y=1.0/x;elsey=1.0;
随机试题
寒凝血瘀型痛经的临床特点是()
材料采购合同履行中,双方发现对部分货物的交货地点约定不明确,则可()确定交货地点。
一小朋友将单词village的字母顺序写错了,那么这个小朋友写出的这个错误单词有多少种可能?
以下______地址是MAC地址。
Ifthevariousadvocatesoftheconflictingoptionsareallsmart,experienced,andwell-informed,whydotheydisagreesocompl
Minipresentation’-about6minutesInthispartofthetestyouareaskedtogiveashorttalkonabusinesstopic,Youhavet
Onereactiontoalltheconcernabouttropicaldeforestationisablankstarethatasksthequestion,"SinceIdon’tliveinthe
Thepoliceweregivenanorderthatthestolendocumentsmustberecoveredatall().
Thethoughtofgoingbackhomewas______kepthimhappywhilehewasworkingabroad.
Afterconsideringforasecond,he______thatthishospitalwasthebestofallinChinaandsaidIcouldbelievehimforsure.
最新回复
(
0
)