读书人

template中能带cout吗?该怎么处理

发布时间: 2012-03-15 11:50:38 作者: rapoo

template中能带cout吗?
今天用模板做一个函数 但是在模板函数中的输出没有显示,请问大虾这是怎么会事?
最好给详细解答!

[解决办法]

#include "iostream "

using namespace std;


template <typename T>
void Print(T t)
{
cout < <t < <endl;
}


int main()
{
Print(100);
Print( "Hello STL ");
Print(1.23f);

return 0;
}

读书人网 >C++

热点推荐