提示:
D:C programLightOjmain.cpp|8|error: 'to_string' is not a member of
'std'|
这是代码:
// to_string example
#include <iostream> // std::cout
#include <string> // std::string, std::to_string
int main ()
{
std::string pi = "pi is " + std::to_string(3.1415926);
std::string perfect = std::to_string(1+2+4+7+14) + " is a perfect number";
std::cout << pi << '\n';
std::cout << perfect << '\n';
return 0;
}
IDE是code::blocks,请问这个是为什么呢?
Check your compiler version to see if it supports c++11 features and whether it supports this new standard library function
Try setting it in the codeblock to compile according to c++11. The setting method is http://www.360doc.com/content... .
If it still doesn’t work, it should be because the compiler doesn’t support it as mentioned above