首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class xx{ int x; public: XX(int xx=0):x(xx){} int ge
有如下程序: #include<iostream> using namespace std; class xx{ int x; public: XX(int xx=0):x(xx){} int ge
admin
2020-07-30
22
问题
有如下程序:
#include<iostream>
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<<c.getV()+c.getX()<<endl;
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/pCyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列关于运算符重载的描述中,正确的是()。
若有下面的函数调用:fun(a+b,3,max(n一1,b)则fun的实参个数是()。
请编写函数fun,该函数的功能是:统计一行字符串中单词的个数,作为函数值返回。字符串在主函数中输入,规定所有单词由小写字母组成,单词之间有若干个空格隔开,一行的开始没有空格。注意:部分源程序在文件PROGl.C中。请勿改动main函数
下列给定程序中,函数fun的功能是:将形参S所指字符串中下标为奇数的字符按ASCII码大小递增排序,并将排序后下标为奇数的字符取出,存入形参P所指字符数组中,形成一个新串。例如,形参s所指的字符为“baawrskjghzlicda”,执行后P所指
编写函数fun,其功能是:求Fibonacei数列中大于t的最小的数,结果由函数返回。Fibonacci数列F(n)的定义为:F(0)=0,F(1)=1F(n)=F(n一1)+F(n一2)例如,当t=1000时,函数值为159
给定程序中,函数fun的功能是:调用随机函数产生20个互不相同的整数放在形参a所指数组中(此数组在主函数中已置0)。请在程序的中括号处填入正确的内容并把中括号删除,使程序得出正确的结果。注意:部分源程序在文件BLANKl.C中。不得增行
给定程序MODll.c中,函数fun()的功能是统计S所指一维数组中0的个数(存在变量zero中)和l的个数(存在变量orle中),并输出结果。请改正函数fun中指定部位的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行
通过运算符重载,可以改变运算符原有的()。
使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。(1)重载运算符int,请在注释//********1********后添加适当的语句。(2)重载运算符“<<”请在注释//****
随机试题
使用代理人来代表自己参与谈判,关键是()
患者,女,20岁。晨起在操场跑步中突然摔倒,意识不清,呼吸慢呈叹息样,桡动脉脉搏触不到,5分钟内送入校医院抢救。检查:意识完全丧失,颜面青紫,大小便失禁,呼吸停止,心音消失,股动脉脉搏消失,血压测不出。现场判断该患者发生心脏骤停的主要征象是
A.磷酸锌水门汀B.聚羧酸锌水门汀C.玻璃离子水门汀D.氢氧化钙水门汀E.氧化锌丁香酚水门汀可用作深龋垫底的材料的是
男,37岁,因外伤至前牙折断,检查,右上侧切牙冠折其折裂线约在龈下1.5mm,若进行桩冠修复,除作牙髓治疗外,还应作
根据《招标投标法实施条例》,招标人可以对已发出的招标文件进行必要的澄清或者修改。澄清或者修改的内容可能影响投标文件编制的,招标人应当在提交投标文件截止时间至少()日前,以书面形式通知所有获取招标文件的潜在投标人。
检查口、清扫口和室内检查井等清通设备,其作用是()。
当选中要删除的文件时,删除此文件可以采取下列()方法。
2011年6月30日,国务院正式批准设立浙江舟山群岛新区。舟山群岛的普陀山是中国四大佛教名山之一,下列哪一项不是四大佛教名山?()
写出下列汉字的韵母:国()、但()、胎()、风()、江()、裕()、盆()、九()、轮()、对()。
在任务分解中已列出每个工作单元与其他工作单元的关系,据此可梳理出各工作单元之间的依赖关系。依赖关系反映了任务顺序。依赖关系可分为()。Ⅰ.强制依赖关系Ⅱ.可斟酌处理的依赖关系Ⅲ.外部依赖关系Ⅳ.内部依赖关系
最新回复
(
0
)