一. g++ 编译 带template 方法,失败 err: undefined reference to , 找不到链接函数
原因: g++ 不完善, g++不支持模板类的分离编译
.h 如此定义
template<class T>
static std::string to_string(const T &t);
把实现此方法的内容也在放到.h
template<class T>
std::string CStringTooler::to_string(const T &t) {
std::stringstream ss;
ss << t;
return ss.str();
}
便可编译通过。