Sat*_*evi 9 c++ iterator compiler-errors std syntax-error
我正在尝试执行以下操作:
source = new int[10];
dest = new int[10];
std::copy( std::begin(source), std::end(source), std::begin(dest));
Run Code Online (Sandbox Code Playgroud)
但是,编译器报告以下错误.
copy.cpp:5434:14: error: ‘begin’ is not a member of ‘std’
copy.cpp:5434:44: error: ‘end’ is not a member of ‘std’
copy.cpp:5434:72: error: ‘begin’ is not a member of ‘std’
Run Code Online (Sandbox Code Playgroud)
我<iterator>在代码中包含了必需的标头.有人可以帮我这个吗?
Vla*_*cow 13
模板函数std :: begin()和std :: end()没有为指针实现(指针不包含有关它们引用的元素数量的信息)而是你应该写的它们
std::copy( source, source + 10, dest);
Run Code Online (Sandbox Code Playgroud)
至于错误,你应该检查是否包含标题
#include <iterator>
Run Code Online (Sandbox Code Playgroud)
也许你的编译器不支持C++ 2011 Standard.