how to get iterator to a particular position of a vector(如何将迭代器获取到向量的特定位置)
问题描述
假设我有一个
现在我想要一个迭代器,比如说向量的第 10 个元素.
now i want an iterator to, let's say 10th element of the vector.
不做下面的做法
因为这会破坏为向量提供随机访问迭代器的优势.
as this will spoil the advantage of having random access iterator for a vector.
推荐答案
只需将 10 添加到迭代器即可.它们旨在感觉"像指针.
Just add 10 to the iterator. They are intended to "feel" like pointers.
这篇关于如何将迭代器获取到向量的特定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!