J
James Brown
Hi,
I am using the std::vector class as follows:
vector <myclass *> stack1;
and am pushing myclass objects onto the end of the
vector like so:
myclass *ptr = new myclass();
stack1.push_back(ptr);
what I would like to do is pop this item from the end of
the vector as well, however the vector:op_back method does not
return anything (it has a void return-type). So my question is, what
is the preferred, neatest method to pop the last element from a vector
but also retain that value?
maybe iterators or direct-access using the operator[], followed by the
pop_back call?
Basically I'd like to know what the most common method is to do this...
Thanks,
James
I am using the std::vector class as follows:
vector <myclass *> stack1;
and am pushing myclass objects onto the end of the
vector like so:
myclass *ptr = new myclass();
stack1.push_back(ptr);
what I would like to do is pop this item from the end of
the vector as well, however the vector:op_back method does not
return anything (it has a void return-type). So my question is, what
is the preferred, neatest method to pop the last element from a vector
but also retain that value?
maybe iterators or direct-access using the operator[], followed by the
pop_back call?
Basically I'd like to know what the most common method is to do this...
Thanks,
James