“to_string” isn't a member of “std”?

18 down vote

to_string works with the latest C++ versions like version 11. For older versions you can try using this function

#include <string>
#include <sstream>

template <typename T>
std::string ToString(T val)
{
    std::stringstream stream;
    stream << val;
    return stream.str();
}

By adding a template you can use any data type too. You have to include #include<sstream> here.

猜你喜欢

转载自blog.csdn.net/qq_37405874/article/details/82590662
今日推荐