C++ 向量迭代器
示例
begin将an返回iterator到序列容器中的第一个元素。
end返回iterator末尾的第一个元素。
如果矢量对象const,无论是begin和end返回const_iterator。如果const_iterator即使向量不返回,也要返回const,则可以使用cbegin和cend。
例:
#include <vector>
#include <iostream>
int main() {
std::vector<int> v = { 1, 2, 3, 4, 5 }; //使用initializer_list初始化向量
for (std::vector<int>::iterator it = v.begin(); it != v.end(); ++it) {
std::cout << *it << " ";
}
return 0;
}输出:
12345
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下