Tag Archives: string

c++中的string转换

如何转换string到其他类型?如何从其他类型转换到string? 代码1:toString template <class T> std::string toString(const T& a) { std::ostringstream ost; ost << a; return ost.str(); } 代码2:fromString template<typename T>T fromString( const std::string& s) { std::istringstream is(s); T t; is >> t; return t; } 使用方法: int d = … Continue reading

Posted in Program | Tagged , , | Leave a comment