The prototype of std::vector::resize() is:
void resize( size_type count, T value = T() );
Thus, it creates a temporary default value that needs to be inserted into the vector (your constructor call), then it is copied 10 times into the vector (you do not register them), and then the temporary one is destroyed (your destructor is called).
Note that for C ++ 11, everything has changed. Now there are two overloads:
void resize( size_type count ); void resize( size_type count, const value_type& value);
So, if you use the correct C ++ 11 compiler, you will call the first overload, and your values will be initialized with a value, that is, it will use the default constructor.
rodrigo
source share