dose vector.erase() call destructor

Started by
4 comments, last by Zahlman 19 years, 4 months ago
if you have a vector of objects and call erase on one of them dose it call the destuctor? thanks[grin]
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
Advertisement
Yes.
ok thanks alot just wanted to know
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
But if you're using a vector of pointers (as you have in your earlier examples today) it doesn't delete the objects (or run their destructors) - it just kills the pointers.
lol youve been doing some reading eh?
i figured as much about the pointers.
thanks[smile]

(yeah i have alot of vector posts for today after i decided that i should make all my 1d arrays vectors, the conversion was a little messy but i learned alot and it all works properly now)
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
Also, remember that the vector *copies* your object upon insertion, so the original (assuming heap allocation) does not get deleted (and thus does not have its destructor called).

This topic is closed to new replies.

Advertisement