我正在阅读C++ Primer 5th Edition
这本书。有时,作者会使用函数 begin
和 end
。
例如:
int ia[3][4] = {0,1,2,3,4,5,6,7,8,9,10,11};
int (*p)[4] = begin(ia);
但是,我得到了错误:
error: ‘begin’ was not declared in this scope
我正在运行 gcc 4.9.2,我使用以下命令进行编译:
g++ -std=c++11 main.cpp
最佳答案
作者可能有类似using namespace std;
的声明或 using std::begin;
.您需要输入 std::begin
没有其中之一。您可能还需要 #include<iterator>
.
关于C++ 开始()和结束(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31139111/