题目内容:
使用VC++6.0打开考生文件夹下的源程序文件1.cpp,该程序运行时有错误,请改正错误,使得程序输出: Hello
test
注意:不要改动main函数,不能增加或删除行,也不能更改程序的结构,错误的语句在
//******error******的下面。
试题程序:
#include<iostream>
//********error********
template<T>
voidfun(Tt)
{
std::cout<<"test"<<std::endl;
}
//********error********
template<bool>
voidfun(boolt)
{
std::cout<<(t?"Hell0":"Hi")<<std::endl;
}
intmain()
{
//********error********
boolflag=TRUE;
fun(flag);
fun((int)flag);
return0;
}
参考答案:
答案解析: