【发布时间】:2014-02-28 21:12:08
【问题描述】:
1>c:\users\indira\documents\visual studio 2012\projects\cpppremier\cpppremier\ch1.cpp(2060): error C3861: 'begin': identifier not found
1>c:\users\indira\documents\visual studio 2012\projects\cpppremier\cpppremier\ch1.cpp(2060): error C3861: 'end': identifier not found
========== 构建:0 成功,1 失败,0 最新,0 跳过 ==========
#include <iostream>
#include <string>
#include <cstddef>
#include<array>
#include<vector>
#include <iterator>
using std::string;
using std::cin;
using std::cout;
using std::endl;
int main()
{
int ia[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int *pbeg = begin(ia), *pend = end(ia);
cout << "Elements in arr: " << endl;
for (int *pbeg; pbeg != pend; ++pbeg)
{
*pbeg = 0;
cout << *pbeg << endl;
}
getchar();
getchar();
return 0;
}
我不明白为什么这不起作用。我正在尝试使用迭代器标头来使用该标头中定义的开始和结束函数。 该代码具有迭代器标头。这些函数将数组作为参数,因为数组不是类类型...... 我在 Visual Studio 2013 和 compileonline.com c++11 中尝试过。
【问题讨论】: