1. Does .clear() member function in a vector free() memory called by new?
I wrote some code to check it out. I think the answer is no, because my destructor does not appear to be called. Am I right about this? (Code Below.)
2. When I go through a vector as in the loop below, I have to declare a const iterator like so:
for( vector<int>::const_iterator itr; blah; blah)
Is there anyway to declare itr by the variable name and not the variable's type? So:
for( points::const_iterator itr; blah; blah)
The reason for this, is because sometimes I want to change the variable's type, and now I have to go through and change my loop too. Plus writing vector<int>::const_iterator is rather verbose.
thanks!
/* vectorclear.cpp
does clearing a vector free allocated memory with new?
*/
1. Does .clear() member function in a vector free() memory called by new?
I wrote some code to check it out. I think the answer is no, because my destructor does not appear to be called. Am I right about this? (Code Below.)
Part of code as follows: std::vector<ClearPoint*> points;
Fatal error in understanding here - you have a vector of pointers.
when the vector does a clear() - it only clears out the pointers - the
destructors of the objects that the pointers are referencing are not going to get called.