首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class AA{ int k; protected: int n; void setK(int k)
有如下程序: #include using namespace std; class AA{ int k; protected: int n; void setK(int k)
admin
2019-05-06
27
问题
有如下程序:
#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
解析
因为类BB公有继承自类AA,所以AA中的保护成员和公有成员在类BB中仍是保护成员和公有成员。在选项B中调用了公有成员函数setN(int n){this->n=n;),对保护成员n进行赋值操作。
转载请注明原文地址:https://kaotiyun.com/show/ks8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
如下程序的输出结果是#include<lostream>#include<cstring>usingnamespacestd;classXCD{char*a;intb;public:X
支持子程序调用的数据结构是
下列语句中正确的是
当循环队列非空且队尾指针等于队头指针时,说明循环队列已满,不能进行入队运算。这种情况称为
下列关于this指针的叙述中,正确的是()。
______是一种特殊的成员函数,它主要用来为对象分配内存空间,对类的数据成员进行初始化并执行对象的其他内部管理操作。
如果表达式x=y*z中的*是作为成员函数重载的运算符,采用运算符函数调用格式,该表达式还可以表示为______。
A、 B、 C、 D、 C只有在创建对象时才会调用类的构造函数,在定义指针时不会调用构造函数,只有给指针new一个地址时会调用构造函数,所以本程序中一共生成了6个Point对象(A,B,C,newPoint[
A、 B、 C、 D、 C数据库系统(DBS)由数据库(DB)、数据库管理系统(DBMS)、数据库管理员、硬件平台和软件平台5个部分组成,可见DB和DBMS都是DBS的组成部分。
下面的符号中可以用作C++标识符的是()。A)3testB)fcc~othterC)elseD)radius
随机试题
足部十二指肠反射区在胰反射区()。
A.内痔B.外痔C.混合痔D.肛瘘E.肛裂
肺主通调水道的功能主要依赖于
依据《中华人民共和国行政处罚法》以及《道路运输行政处罚规定》的规定,道路运输行政处罚的原则主要包括()。[2008年真题]
“稀土”是宝贵的战略资源,我国已建立出口管制措施。都是稀土元素,下列有关说法错误的是()。
某高校艺术学院分音乐系和美术系两个系别,已知学院男生人数占总人数的30%,且音乐系男女生人数之比为1:3,美术系男女生人数之比为2:3。问音乐系和美术系的总人数之比为多少?()
热水瓶:保温杯
计算机中控制器的功能主要是
Agoodmodernnewspaperisanextraordinarypieceofreading.Itisremarkablefirstforwhatitcontainstherangeofnewsfrom
Whatactually______agoodangle—oragoodselfieoverall—isrootedinwhatweconsiderbeautiful.
最新回复
(
0
)