vector problem

Hey all,

vec is a vector.
I deleted value at vec[i2-1]

Shape* r1 =vec.at(i2)
vec.erase(vec.begin() +i2-1);
delete r1;

now i want to print all values in vector, but there is aproblem with vec[i2], what does it contain ? NULL ?
please help !
Thank u
Last edited on
well you have already used the member function begin(). there is also a member function.called end() which returns a pointer one.past the last element. or there is size(). just use one of those as a stop condition. if you want to check out what member functions vector has.google vector c++ and click on the reference.
The value at vec[i2-1] is what was previously at vec[i2], unless there was no element at vec[i2], and then vec[i2-1] is no longer a valid subscript.

Topic archived. No new replies allowed.