首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class XX{ int x; public: XX(int xx=0):x(xx){} int getX(){return
有如下程序: #include using namespace std; class XX{ int x; public: XX(int xx=0):x(xx){} int getX(){return
admin
2020-04-07
33
问题
有如下程序:
#include
using namespace std;
class XX{
int x;
public:
XX(int xx=0):x(xx){}
int getX(){return x;}
};
class YY:public XX{
int y;
public:
YY(int xx,int yy):XX(xx),y(yy){}
int getV(){return getX()+y;}
};
int main(){
YY c(3,4);
cout<
return 0;
}
运行这个程序的输出结果是( )。
选项
A、3
B、4
C、7
D、10
答案
D
解析
由于类YY公开继承自类XX,所以执行表达式c.getV()+c.getX()的值等于3+3+4=10。
转载请注明原文地址:https://kaotiyun.com/show/g88p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列函数的运行结果是#include<iostream.h>intf(inta,intb){intc;if(a>b)c=1;elseif(a==b)C=0;elsec=-1;ret
数据库设计的根本目标是要解决
下述关于数据库系统的叙述中正确的是
设一棵完全二叉树共有839个结点,则在该二叉树中有【 】个叶子结点。
要建立文件流并打开当前目录下的文件file.dat用于输入,下列语句中错误的是
有些运算符既可以作为成员函数重载,也可以作为非成员函数重载。若在一个重载的运算符函数的定义中成功地使用了this指针,说明它是作为【13】重载的
若将一个二元运算符重载为类的成员函数,其形参个数应该是______个。
在关系数据库中,用来表示实体之间联系的是
对下列二叉树进行中序遍历的结果是()。
C++目标程序经【】后生成扩展名为exe的可执行程序文件。
随机试题
下列情况中,检查气管向左侧移位的是【】
2003年4月,WHO宣布,2002年出现的传染性非典(SARS)病原体为新的
左归丸与一贯煎相同的功用是
下列溶液中,宜用气相色谱电子捕获检测器测定残留量的是()。
建设单位甲将某工程承包给建筑企业乙建造,丙为该工程监理公司,建筑企业乙为该工程投保了建筑工程一切险,则下列说法正确的是( )。
“进口口岸”栏应填:“运费”栏应填:
保险监督管理机构应当建立健全保险公司偿付能力监管指标体系,对保险公司的最低偿付能力实施监控。( )
某商品打7.5折后,商家仍然可得25%的利润。如果该商品是以每件16.8元的价格购进的,问该商品在货架上的标价是多少?
社会主义法治最根本的保证是()
Whydoestheideaofprogressloomsolargeinthemodernworld?Surelybecauseprogressofaparticularkindisactually【C1】___
最新回复
(
0
)