error: ‘to_string’ was not declared in this scope

错误:

error: ‘to_string’ was not declared in this scope

 

原因:

to_string是C++11引入的新功能,旧版本编译器可能不支持它,所以要给编译器加上“C++11”编译支持

 

解决方案:

Linux下的GCC编译器:在 g++ 命令行加入编译选项 -std=c++11,例如:

g++ -o test test.cpp -std=c++11

 

CodeBlocks编译器:工具栏打开Settings->Compiler,在这里勾选C++11标准即可。(参考链接

 

Dev C++ 编译器:在菜单栏点开Tools -> Compile Options,加上圈住的编译指令即可让编译器支持c++11的标准。(参考链接)

 

posted @ 2018-10-16 11:39  Cyril_Wu  阅读(9812)  评论(2编辑  收藏  举报