首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
2015-06-27
27
问题
有如下程序:
#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/1RNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在软件开发中,下面任务不属于设计阶段的是()。
十进制数28和3.26的类型分别为【】和【】。
多数运算符既能作为类的成员函数重载,也能作为类的非成员函数重载,但口运算符只能作为类的【】函数重载。
若已定义,以下fun函数的功能是:在第一个循环中给前10个数组元素依次赋1、2、3、4、5、6、7、8、9、10;在第二个循环中使a数组前10个元素中的值对称折叠,变成1、2、3、4、5、5、4、3、2、1。请填空。fun(inta[])
下列程序将x、y和z按从小到大的顺序排列,请将下面的函数模板补充完整。template<classT>voidorder(【】){Ta;if(x>y){a=X;x=y;y=a;}if(
以下程序输出的结果是【】。#include<iostream.h>voidmain(){inta=5,b=4,c=3,d;d=(a>b>c);cout<<d;}
若已定义的函数有返回值,则以下关于该函数调用的叙述中错误的是()。
运算符重载是对已有的运算符赋予多重含义,因此()。
下面叙述错误的是______。
下面有关重载函数的说法中正确的是
随机试题
副交感神经的主要功能是()。
大拉翅旗头在清代初期就已经普遍流行。()
以下辅料在片剂中作崩解剂的是
引起胰腺细胞坏死的是
简要概述消防车登高操作场地的检查方法的主要操作内容。
2020年1月,甲公司与乙公司签订劳务派遣协议,派遣刘某到乙公司从事临时性工作。2020年5月,临时性工作结束,两公司未再给刘某安排工作,也未再向其支付任何报酬。2020年7月,刘某得知自2020年1月被派遣以来,两公司均未为其缴纳社会保险费,遂提出解除劳
根据《浙江省旅游管理条例》规定,设立旅游度假区,应当报省人民政府和国务院批准。()
设对(Ⅰ)中的任意向量ξ2,ξ3,证明ξ1,ξ2,ξ3线性无关。
Thosewhowishtoscheduletheirannualcheck-upscancallusandmake______inadvance.
Petroleumproducts,suchasgasoline,kerosene,homeheatingoil,residualfueloil,andlubricatingoils,comefromonesource
最新回复
(
0
)