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