It appears that you're putting integers into the array but then treating them as pointers in the first line of your destructor. I think you want
: Now I notice that you're passing a pointer
to each integer when you add it to the array. But the integer comes from the loop variable
, which will cause problems when you try to delete it, because it was an address on the stack.
The convention, when writing a container, is for it to hold instances of
. When the container is meant to hold pointers, then the code using
the template should specify this explicitly.