0
我想Cygwin中使用G ++(4.8.1版本)編譯下面的代碼,它似乎無法使用功能STOD():克++ STOD「在此範圍內未聲明
//test.cpp
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
string a="1.23";
cout<<stod(a);
return 0;
}
我不斷收到這個eroor:
test.cpp:9:14: error: 'stod' was not declared in this scope
cout<<stod(a);
,我讀了有同樣的問題另一個線程。在那裏,人們建議使用C++ 11來解決它。所以,我想這兩個下面的命令來編譯它,但仍然得到了同樣的錯誤:
g++ -std=c++0x test.cpp -o test
g++ -std=c++11 test.cpp -o test
有誰知道解決這個問題呢?
我如何知道C++ 11已啓用?我是否需要修改我的代碼才能使用它?
非常感謝!
@ 101010'-std = C++ 0x'和'-std = C++ 11'完全一樣。 – hvd
@ hvd對不起,不知道。 – 101010
這是一個很好的問題。我完全在linux中拷貝你的代碼(ubuntu 16.04和g ++ 5.03),它的工作原理並沒有給出任何錯誤。 –