std::vectors, can be answered in 2 seconds

Started by
7 comments, last by GameDev.net 18 years, 4 months ago
Hello I have a little question about vectors: if I do MYVEC.push_back(x); can I assume that *MYVEC.end() == x? is a pushed_back item put at the vector.end()?
Advertisement
NO! end() points after the last element. MYVEC.back() == x, though.
Quote:Original post by Sneftel
NO! end() points after the last element. MYVEC.back() == x, though.


* 2...

Seriously, I'm not joking, when you multiply that by 2 you get NO!NO!.

Anyways, YOURVEC.end() is 1 past the end, not the back. '.back()' as sneftel said, would work.

C++
Original post by Trillian
Hello

I have a little question about vectors:
if I do
MYVEC.push_back(x); <
Original post by Anonymous Poster
Original post by Trillian
Hello

I have a little question about vectors:
if I do
MYVEC.push_back(x); <
WTF?

WHATS HAPPENNING TO MY STUPID POSTS!!!!!!!

I MEANT, WHY ARE YOU USING A NON POINTER AND LATER A POINTER?
He was dereferencing the iterator returned by end().
exactly, and I thank you all for the replies :)
Quote:Original post by Sneftel
He was dereferencing the iterator returned by end().


Ohh.... Gotcha. That's when '(' and ')' kick in lol:
//pointer(*pVec).end();//dereferencing*(Vec.end());

This topic is closed to new replies.

Advertisement