Aer*_*lSP 11 c++ compiler-errors g++ std c++-standard-library
当我尝试使用std :: stoi并尝试编译它时,我收到错误消息"stoi不是std的成员".我从命令行使用g ++ 4.7.2所以它不能是IDE错误,我按顺序包含所有我的包含,而g ++ 4.7.2默认使用c ++ 11.如果有帮助,我的操作系统是Ubuntu 12.10.有没有配置的东西?
#include <iostream>
#include <string>
using namespace std;
int main(){
string theAnswer = "42";
int ans = std::stoi(theAnswer, 0, 10);
cout << "The answer to everything is " << ans << endl;
}
Run Code Online (Sandbox Code Playgroud)
不会编译.但它没有任何问题.
小智 16
std::stoi()是C++ 11中的新功能所以你必须确保用以下代码编译它:
g++ -std=c++11 example.cpp
Run Code Online (Sandbox Code Playgroud)
要么
g++ -std=c++0x example.cpp
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19259 次 |
| 最近记录: |