Tuesday, 10 September 2013

iterator for the last element of a vector

iterator for the last element of a vector

I need to get an iterator to the last element in a std::vector.
As known end() method returns an iterator referring to the past-the-end
element in the vector container. Can I implement what I need by using
end() - 1?
As far as I understand I can't use back() method, since it returns a
reference.

No comments:

Post a Comment