新手来了 我刚从终端运行我编写的 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27377 次 |
| 最近记录: |