新手在这里。我刚从终端运行我编写的C ++程序时遇到了一个错误error: ‘stoi’ is not a member of ‘std’
。他们告诉我编译器太旧了。
我正在使用Ubuntu 14.04。
我的g ++版本是4.8.4。
我该如何升级?
您不需要升级。将标准版本指定为g++
。例如,要从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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句