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的标准。(参考链接)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM