首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class XX{ int x; public: XX(intxx=0):x(xx){} int getX(){ret
有如下程序: #include using namespace std; class XX{ int x; public: XX(intxx=0):x(xx){} int getX(){ret
admin
2016-11-25
18
问题
有如下程序:
#include
using namespace std;
class XX{
int x;
public:
XX(intxx=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()+e.getX()的值等于3+3+4=10。
转载请注明原文地址:https://jikaoti.com/ti/Pvt0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
一个函数为voidf(int,charch=’a’),另一个函数为voidf(int),则它们
关于read()函数的下列描述中,正确的是()。
关于友元的概念错误的是()。
若要把函数voidf()定义为aClass的友元函数,则应该类aClass的定义中加入的语句是()。
运算符重载仍然保持其原来的优先级、______和______。
______使一个函数可以定义成对许多不同数据类型完成同一个任务。
对于派生类的构造函数,在定义对象时构造函数的执行顺序为:先执行调用______的构造函数,再执行调用子对象类的构造函数,最后执行派生类的构造函数体中的内容。
假设线性表的长度为n,则在最坏情况下,冒泡排序需要的比较次数为
模板使我们可以用一个代码段指定一组相关函数(称为______)或一组相关类(称为______。
类MyClass的定义如下:classMyClass{public:MyClass(){value=0;}SetVariable(inti){value=i;)
随机试题
根据《重要地理信息数据审核公布管理规定》,重要地理信息数据公布时,应当说明()。
下列哪项不属于项目建议书编制的内容()
海关批准进口货物保税的原则为()。
报关单位申报出料加工货物出境时应向海关提交出料加工登记手册、出口货物报关单、货运单据及其他海关需要的报关单证;属于应征出口税的商品,应向海关提供担保,属于许可证件管理的商品,应向海关提交许可证件。()
下列情况下,企业可将其他资产转换为投资性房地产的有()。
AlexisdeTocqueville,theFrenchpoliticalscientist,historian,philosopherandpolitician,ismostfamousforafour-volumeb
某车间需要用一台车床和一台铣床加工A、B、C、D四个零件。每个零件都需要先用车床加工,再用铣床加工。车床与铣床加工每个零件所需的工时(包括加工前的准备时间以及加工后的处理时间)如表3。若以A、B、C、D零件顺序安排加工,则共需32小时。适当调整零件加工
下图是在一台Windows主机在命令行模式不执行某个命令时用sniffer捕获的数据包。请根据图中信息回答下列问题。该主机上执行的命令是【5】。
下列各组排序法中,最坏情况下比较次数相同的是()。
Theteam______itswinningseasontohardworkanditsnewcoach.
最新回复
(
0
)