I am trying to compile the following code using g++ (version 4.8.1) in cygwin, and it seems that it cannot use the function stod():
//test.cpp
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
string a="1.23";
cout<<stod(a);
return 0;
}
I keep getting this eroor:
test.cpp:9:14: error: 'stod' was not declared in this scope
cout<<stod(a);
I read another thread that has the same problem. There, people suggested to use c++11 to address it. So I tried both the following commands to compile it but still got the same error:
g++ -std=c++0x test.cpp -o test
g++ -std=c++11 test.cpp -o test
Does anyone know a solution to this problem?
And how do I know that c++11 is enabled? Do I need to modify my code in order to use it?
Thanks a lot!