首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; int fun1(int x) { return ++x; } int fun2(int& x) { re
有如下程序: #include using namespace std; int fun1(int x) { return ++x; } int fun2(int& x) { re
admin
2021-05-06
23
问题
有如下程序:
#include
using namespace std;
int fun1(int x) { return ++x; }
int fun2(int& x) { return ++x; }
int main() {
int a=0,b=0,c=0;
c=fun1(a)+fun2(b);
cout<
return 0;
}
运行后的输出结果是
选项
A、002
B、012
C、102
D、112
答案
B
解析
程序定义了两个函数,fun1和fun2,功能都是对形参x自增1,然后返回自增后的值,其中fun2的形参x为引用类型,形参x自增1的同时实参的值也自增1;main函数中定义三个整型变量a=0,b=0,c=0,调用fun1(a)返回值为1,调用fun2(b)返回值为1,同时实参b的值被修改为1,所以c的值为1+1=2,程序输出a、b、c为0,1,2;答案为B。
转载请注明原文地址:https://kaotiyun.com/show/0Dfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:classBase{public:intdata;};classDerivedl:publicBase{};classDerived2:protectedBase{};
有类定义如下:classType{public:Type(inti=0);Typeoperator一(int);friendTypeoperator+(Type,Type);pri
在软件开发中,需求分析阶段产生的主要文档是()。
对长度为n的线性表排序,在最坏情况下,比较次数不是n(n-1)/2的排序方法是()。
若要重载+、=、<<、==和口运算符,则必须作为类成员重载的运算符是()。
若实体A和B是一对多的联系,实体B和C是一对一的联系,则实体A和C的联系是
下列关于C++预定义流对象的叙述中,正确的是()。
下面是类shape的定义:classShape{public:VirtualvoidDraw()=0;};下列关于Shape类的描述中,正确的是()。
若需要为XV类重载乘法运算符,运算结果为XV类型,在将其声明为类的成员函数时,下列原型声明正确的是()。
下列选项中,不是C++关键字的是()。
随机试题
A.右下肺文变阴影B.右下肺炎性阴影伴空洞有液平C.双下肺环状、卷发状阴影D.两肺多发性结节阴影支气管扩张
A.肺内压B.胸膜腔内压C.肺泡表面张力D.跨肺压E.跨胸壁压有助于肺保持扩张状态的是
关于合同中的技术标准和图纸地位的说法,不正确的是()。
企业已经确认销售商品收入发生销售折让时,应冲减当月的销售商品收入,不应该冲减销售商品的成本和相应的增值税销项税额。()
根据以下资料,回答下列问题。2006年某省从事高新技术产品出口的企业共计1.65万家,比2002年翻了一番。各类企业在数量上保持了增长态势,其中国有企业数量比2002年增长11%,合资企业数量增长23%,外商与港澳台商独资企业数量增长了1.5倍,集体企业
一台安装了签名识别软件的电脑——这种软件仅限于那些在文档中签名的人进入计算机——不仅通过分析签名的形状,而且通过分析诸如笔尖的压力和签名的速度等特征来识别某人的签名。即使是最机灵的伪造者也不能复制该程序能分析的所有特征。以下哪项结论能合逻辑地从上述陈述中推
A、连续但不可偏导B、可偏导但不连续C、可微D、一阶连续可偏导C
Aspartofmorecomprehensivecomplianceandethicsprograms,manycompanieshaveformulatedinternalpoliciespertainingtothe
Itisconsideredunwisetogiveachild______heorshewants.
A、Takesomeextratime.B、Putdownwhateverideasshehasfirst.C、Dosomeworkforanothercourse.D、Writethestoryendingfir
最新回复
(
0
)