首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class AA{ int k; protected: int n; void setK(int k){th
有如下程序: #include<iostream> using namespace std; class AA{ int k; protected: int n; void setK(int k){th
admin
2020-11-11
18
问题
有如下程序:
#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
解析
因为类BB公有继承自类AA,所以AA中的保护成员和公有成员在类BB中仍是保护成员和公有成员。在选项B中调用了公有成员函数setN(int n){this->n=n;},对保护成员n进行赋值操作。
转载请注明原文地址:https://kaotiyun.com/show/M0yp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在数据处理中,其处理的最小单位是()。
使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成函数fun(intx),该函数功能是判定x的所有的约数,并且在函数中调用写函数WriteFile()将结果输出到modi2.txt文件中。例如:x=10的约数为1,2,5,10。
使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为:10注意:错误的语句在//********error********的下面,修改该语句即可。#includ
使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为:1063022注意:错误的语句在//********error********
使用VC6打开考生文件夹下的源程序文件modi3.epp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能:(1)定义纯虚类TestClass0,包含纯虚函数fun(),请在注释//********1********后添
对于长度为n的线性表,在最坏情况下,下列各排序法所对应的比较次数中正确的是()。
软件按功能可以分为:应用软件、系统软件和支撑软件(或工具软件)。下面属于应用软件的是()。
下列叙述中正确的是()。
定义派生类时,若不使用关键字显式地规定采用何种继承方式,则默认方式为( )。
对如下二叉树进行后序遍历的结果为
随机试题
计算二重积分(3x+2y)dσ,其中D是由两坐标轴及直线x+y=2所围成的闭区域.
患者,男性,35岁,滞留,X线片显示横位埋伏于处并与其影像重叠。术中发现埋伏牙根很长,且牙冠紧卡在两根之间,挺无松动,这时最佳选择是
尖锐湿疣之湿毒下注证应选用的方剂是
抢救糖尿病酮症酸中毒应用碳酸氢钠的指征是
位于A市甲区的天力技术公司与位于B市乙区的华融公司签订一份合作开发并经营游戏软件的合同,合同约定:由天力技术公司负责前期的市场调研和软件研发,华融公司主要负责软件的市场经营拓展与销售。此外,补充合同约定:因合同履行所发生的一切争议,双方协商不成的,由A市仲
对于已发生法律效力的判决、裁定有下列哪些情形,当事人申请再审的,法院应当再审?()
人防工程内设置有旅店、病房、员工宿舍时,不得设置在地下()及以下层,并应划分为独立的防火分区,其疏散楼梯不得与其他防火分区的疏散楼梯共用。
未作为资产和负债确认的项目,按照税法规定可以确定其计税基础的,该计税基础与其账面价值之间的差额属于()。
一位教师兴致勃勃地走进教室,突然发现黑板上画了一幅自己的画像,引起课堂上一阵骚动。下列处理方式,最恰当的一项是:
【2015年第46题】有人认为,任何一个机构都包括不同的职位等级或层级,每个人都隶属于其中的一个层级。如果某人在原来级别的岗位上干得出色,就会被提拔,而被提拔者得到重用后却碌碌无为,这会造成机构效率低下、人浮于事。以下哪项如果为真,最能质疑上述观点?
最新回复
(
0
)