首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
64
问题
有如下程序:
#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;classInstrument{public:virtualvoidDisplay()=0;};classPi
有如下语句序列:charstr[10];cin>>str;当从键盘输入”Ilovethisgame”时,str中的字符串是
下面程序的运行结果是_____和_____。#include<iostream.h>#defineN10#defines(x)x*x#definef(x)(x*x)voidmain()
有以下程序main(){inti=0,s=0;do{if(i%2){i++;continue;}i++;s+=i;}while(i<7);cout<<s<<
有以下程序main(){intp[7]={11,13,14,15,16,17,18},i=0,k=0;while(i<7&&p[i]%2){k=k+p[i];i++;)cout<<k<<endl;}
以下程序的输出结果是main(){intnum=0;while(num<=2){num++;cout<<num;}}
如下程序的输出结果是main(){inta=2,b=-1,c=2;if(a<B)if(b<0)c=0elsec++;cout<<c<<endl;}
己知类sample是一个抽象类,其成员函数display是无形参、无返回类型的纯虚函数,请完成其声明:classsample{public:sample(){};______};
随机试题
下列作家与其作品的对应,错误的是()。
幼年类风湿性关节炎湿热流注证的首选方剂是
下列关于完全抗原的说法,正确的是
对于薄钢板法兰的风管,其支、吊架间距不应大于()m。
作为工业生态链中的核心资源,应具有( )。
在有煤尘爆炸危险性的煤矿井下的采区巷道中,常可看到在一段巷道的顶部设置有岩粉棚或水棚,其目的是()。
装于机动车辆上的压缩式空调系统
由ETF基金标的指数调整而出现的现金替代属于()。
下列句子中,加下划线词语的意义解释正确的一项是()。
ThefactthatmostAmericansliveinurbanareasdoesnotmeanthattheyresideinthecenteroflargecities.Infact,moreAme
最新回复
(
0
)