首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
若有以下程序: #include using namespace std; class A { public: A(int i,intj) { a=i: b=j; }
若有以下程序: #include using namespace std; class A { public: A(int i,intj) { a=i: b=j; }
admin
2013-05-30
22
问题
若有以下程序:
#include
using namespace std;
class A
{
public:
A(int i,intj)
{
a=i:
b=j;
}
void move(int x,int y)
{
a+=x;
b+=y;
}
void show()
{
cout(
}
private:
int a,b;
};
class B:private A
{
public:
B(int i,int j):A(i,j){}
void fun()
{
move(3,5);
}
void fl()
{
A::show();
}
};
int main()
{
B d(3,4);
d.fun();
d.fl();
return0:
}
程序执行后的输出结果是( )。
选项
A、3,4
B、6,8
C、6,9
D、4,3
答案
C
解析
此题的执行过程如下:首先B d(3,4);语句调用B类的构造函数:B(int i,intj),B的构造函数中调用基类A的构造函数,使得a=3,b=4;d.fun()会调用函数move(3,5),使得(3,4)和(3,51的对应部分分别相加,最后输出6,9。
转载请注明原文地址:https://kaotiyun.com/show/j2Np777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
阅读下面程序:#include<iostream.h>intfun(inta,intb){intc;c=a*b;returnc;}voidmain(){inta=3,b=5,c=4,x=0;x=fun(fun(a
在一个C++源程序文件中定义的全局变量的有效范围是()。
下列运算符重载函数的原型错误的是()。
假定MyClas为一个类,那么该类的析构函数是()。
不属于结构化程序设计方法主要原则的是()。
在数据流图(DFD)中,带有名字的箭头表示()。
设在主函数中有以下定义和函数调用语句,且fun()函数为void类型,请写出fun()函数的首部【】。intmain(){doubles[10][22];intn;...fun(s);...re
下面关于形参与实参的说法,正确的是()。
对于语句cout<<end1<<x;中的各个组成部分,下列叙述中错误的是______。
在一个C++程序中,每个变量都必须遵循______的原则。
随机试题
醉酒驾驶机动车在道路上行驶会受到什么处罚?
用可能性和现实性的关系解释“水中捞月”和“大海捞针”这两句话的异同()
熟地的作用是长于
A、奥美拉唑B、盐酸赛庚啶C、富马酸铜替芬D、西咪替丁E、法莫替丁结构中含有苯并咪唑环的质子泵抑制剂
“地西泮5mg.po.sos.”属于
裱糊工程中裱糊后的壁纸出现起鼓或脱落,下述哪项原因分析是不正确的?[2006年第44题]
[2005年第59题]高层建筑内设置消防水泵房,以下要求哪条有错?
奥通公司为增值税一般纳税人,适用的增值税税率为17%。2014年12月1日“应付职工薪酬”科目的贷方余额为258万元(其中工资122万元、工会经费2.5万元、职工教育经费12万元、设定提存计划121.5万元)。该企业2014年12月份发生的有关职工薪酬业务
5M1E的5M中,()是最活跃的因素。
设g(x)可导,|g’(x)|<1,且当a≤x≤b时,a<g(x)<b,又x+g(x)-2f(x)=0,若{xn}满足xn+1=f(xn),n=0,1,2,…,x0∈[a,b]。证明:唯一的ξ∈[a,b],使得f(ξ)=ξ.
最新回复
(
0
)