vector Res@iz

Started by
1 comment, last by ToohrVyk 18 years, 4 months ago
does vector.resize(size+1) preserve the elements it have and add just 1 uninitialized slot or it reallocates everything so the 'so-far-stored-data` is lost? TH@Nks AlOTs yuoRs FaiThFuLLy hi Hi and bye ByE
Advertisement
It adds one initialized element to the end of the vector, though it may force a reallocation which causes iterators, pointers and references to be invalidated. However, the value of those elements are preserved.
Quote:From sgi:
void resize(n, t = T())
Inserts or erases elements at the end such that the size becomes n.


Also, '@' and 'a' are not interchangeable.

This topic is closed to new replies.

Advertisement