使用模板类编写通用的任意类型调试输出函数

函数代码如下:

template < class T>
void PrintDebug(LPCSTR mes,const T& debug){
 std::string str = "";
 std::ostringstream oss;
 oss<<"输出调试信息:"<<mes<<"------>"<<debug<<std::endl;
 str = oss.str();
 oss.clear();
 OutputDebugString((LPCSTR)str.data());
}

注意:模板类的声明和实现必须在同一个文件中,不能声明在.h文件,定义在.cpp文件。

posted @ 2012-02-08 13:54  重甲土拨鼠  阅读(218)  评论(0编辑  收藏  举报