Newbie here.
I just got an error running from the terminal a C++ program I wrote: error: ‘stoi’ is not a member of ‘std’
. They told me the compiler is too old.
I'm using Ubuntu 14.04.
My g++ version is 4.8.4.
How do I upgrade?
You don't need to upgrade. Specify the standards version to g++
. For example, to compile an example program from cppreference.com:
$ g++ --version
g++ (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ --std=c++11 -o test test.cpp
$ ./test
std::stoi("45") is 45
std::stoi("3.14159") is 3
std::stoi("31337 with words") is 31337
--std=c++11
? Can't I make C++11 the default standard?