error: ‘stoi’ was not declared in this scope

已经 include 了相应的头文件 string,但是在调用 stoi 函数时提示编译错误:error: ‘stoi’ was not declared in this scope,在谷歌上搜索了一番,原来需要使用 C++11 标准进行编译,改编译命令如下:

问题解决。

“error: ‘stoi’ was not declared in this scope”的12个回复

      1. 谢谢楼博主先 但是还是不太懂 还得麻烦楼主看一下 mpicxx MPI_NB.cpp -o MPI_NBMPI_NB.cpp: In function ‘void decode(char*, std::map, std::allocator >, int, std::less, std::allocator > >, std::allocator, std::allocator >, int> > >&)’:MPI_NB.cpp:102: error: ‘stoi’ was not declared in this scope是在那里加gcc -std=c++11啊博主我的版本是 gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)麻烦楼主了

        1. 我试着在可执行程序MPI_NB.cpp 中加入了g++ filename.cpp -std=c++11 但是还是不对 应该是我的做法不对 麻烦博主指点 谢谢博主了

发表评论