当我尝试使用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;
}
无法编译,但它本身没有问题。