boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - [请教]iterator and reference in C++ vector
相关主题
一个C++的概念问题
Remove elements from multiple vectors in C++
呼唤大侠们,我实在不能实现C++泛型的精神。
C++ vector 一边遍历一边删
C++如何快速输入iterator类型名
请教一个boost::bind的问题
how to read a sentence into a vector of string?
C++ optimization question
C++: What is the difference between the two approaches?
C++ 里面这个 & 是什么意思?
相关话题的讨论汇总
话题: vector话题: element话题: iterator话题: c++话题: reference
进入Programming版参与讨论
1 (共1页)
s*****g
发帖数: 5159
1
The operator [] of a vector returns the reference to an element of the vecto
r
member function .end() returns an iterator of the last element of the vector
.
I want to judge if a particular element is the last element of the vector, b
ut I cannot do the following
s*****g
发帖数: 5159
2
Solved by
vec.end() -------> vec.back()

vecto
vector
b

【在 s*****g 的大作中提到】
: The operator [] of a vector returns the reference to an element of the vecto
: r
: member function .end() returns an iterator of the last element of the vector
: .
: I want to judge if a particular element is the last element of the vector, b
: ut I cannot do the following

z****e
发帖数: 2024
3
vec.end() is pass-the-end element.
vec.rbegin() can be dereferenced to the last element you want
also.
back() is the standard answer.
s*****g
发帖数: 5159
4
Thank you.

【在 z****e 的大作中提到】
: vec.end() is pass-the-end element.
: vec.rbegin() can be dereferenced to the last element you want
: also.
: back() is the standard answer.

1 (共1页)
进入Programming版参与讨论
相关主题
C++ 里面这个 & 是什么意思?
问一个OOP的C++问题
C++11里list迭代器判空仍然知道具体的list对象吗?
C++请教,使用c++ vector iterator后输出vector数据出错
how to write a function take iterators as parameters?
stl的一个问题
stl 的 member type 看起来挺头大的
c++ interview: iterator 和 pointer区别?
C++ Q11: iterator
C++ syntax question
相关话题的讨论汇总
话题: vector话题: element话题: iterator话题: c++话题: reference