未在此范围错误中声明C ++函数

时间:2014-03-01 20:26:53

标签: c++ c++11 compiler-errors scope

我正在编译代码,但我似乎得到了一个错误,即使在我检查我的代码时,我发现我收到此错误也很奇怪。

我的代码:

#include <iostream>
#include <string>

using namespace std;

int main() {
    string s = "2A";
    int n = stoul(s, nullptr, 16);
    cout << n << endl;

    return 0;
}

并在命令行中输入g++ -std=c++11 main.cpp,我正在使用-std=c++11因为函数stoul来自C++11根据此页{{3 }}

我得到的错误如下:

main.cpp: In function 'int main()':
main.cpp:8:30: error: 'stoul' was not declared in this scope
  int n = stoul(s, nullptr, 16);
                              ^

为什么我收到此错误?

0 个答案:

没有答案
相关问题