问题
填空题
使用VC++6.0打开考生文件夹下的源程序文件1.cpp,该程序运行时有错误,请改正错误,使得程序输出:
Hello
test
注意:不要改动main函数,不能增加或删除行,也不能更改程序的结构,错误的语句在//******error******的下面。
试题程序:
#include<iostream>
//********error********
template(T)
void fun(T t)
std::cout<<"test"<<std::end1;
//********error********
template<bool>
void fun(bool t)
std::cout<<(t"Hello":"Hi")<<std::end1;
int main()
//********error********
bool flag=TRUE;
fun(flag);
fun((int)flag);
return 0;
答案
参考答案:删除“template<bool>”。