The array will not be deleted correctly. auto_ptr
uses delete contained_item;
. For an array it would need to use delete [] contained_item;
instead. The result is undefined behavior.
As James McNellis said, you really want std::vector
here -- no new
, no auto_ptr
and no worries.