首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的输出结果是______。 #include<iostream> using namespace std; template<typename T> T fun(T a,T b){return(a<=b)? a:b;}
下列程序的输出结果是______。 #include<iostream> using namespace std; template<typename T> T fun(T a,T b){return(a<=b)? a:b;}
admin
2010-12-16
61
问题
下列程序的输出结果是______。
#include<iostream>
using namespace std;
template<typename T>
T fun(T a,T b){return(a<=b)? a:b;}
int main( )
{
cout<<fun(3,6)<<’,’<<fun(3.14F,6.28F)<<endl;
return 0;
}
选项
答案
3,3,14
解析
本题考核模板函数的使用。C++编译系统将根据实参表中的实参的类型来确定函数的形参列表中的类型。函数fun的功能是返回两者中较小的值,函数调用fun(3,6)返回的值为3,函数调用fun(3.14F,6.28F)返回的值为3.14。
转载请注明原文地址:https://kaotiyun.com/show/DFVp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下叙述中错误的是()。
以下程序的输出结果是()。#include<stdio.h>main(){inta=1,b=3;ifi[(++a<0)&&!(b--<=0))printf(’’%d,%d\n’’,a,b);
若有以下程序#include<stdio.h>main(){ints=0,n;for(n=0;n<4;n++){switch(n){defa
若要建立下图所示的存储结构,以下正确的程序段是()。
有以下程序:#includemain(){FILE*fp;inta[10]={1,2,3,0,0},i;fp=fopen("d2.dat","wb");fwrite(a,sizeof(int),5,f
下面程序的输出结果是()。#includemain(){chara[]={’a’,’b’,’c’,’d’,’f’,’g’},*p;p=a;printf(“%c\n”,*p+4);}
以下关于return语句的叙述中不正确的是()。
以下能正确输出字符a的语句是()。
随机试题
关于青少年阶段的心理健康,叙述错误的是()
与银杏合用出现昏迷的是( )。与银杏合用出现前房出血的是( )。
关于ETF份额的申购与赎回,下列表述错误的是()。
在项目时间管理中,资源平衡就是力求每天的资源需用量接近________。
哈丁争论说,人们使用公共拥有的(即对任何使用者开放的)牧场比使用私人的牧场更不注意。每个放牧者都有过度使用公共土地的冲动,因为从中获得的利益将归于个人,而由于过度使用土地而引起的土地质量下降的成本则由所有使用者分摊。但一项研究比较了2.17亿英亩的公用牧
在VisualFoxPro中,代码片段是指
Readthearticlebelowandchoosethebestsentencefromthelistonthenextpagetofilleachofthegaps.Foreachgap(1-
DorothyThompsonandRebeccaWestwerecareerwomenlongbeforethetermhadbeeninvented.Inthe1930s,whenThompsonandWest
ThewarmingoftheArcticisreleasinganewwaveofbannedtoxicchemicalsthathadbeentrappedintheiceandcoldwater,sci
Forthispart,youareallowed30minutestowriteashortessayentitledInterestCountsbycommentingonthesaying,"Aburden
最新回复
(
0
)