I am quite lost right now. I made a vector class. Everything works how I would like it to work, until the end. When the destructor is called I get an error message: Debug ass
The error means heap corruption. There are lots of ways to corrupt a heap. Like David explained above, freeing a chunk of memory and then writing to it is one way.
Most heaps store some bytes of bookkeeping information before and after your chunk of memory. If your code misbehaves and changes the heaps data, you get this type of error.
_myArray = setterVect._myArray;
Your copy assignment operator is broken. After that operator, both instances have the same value for _myArray
. So as soon as one is destructed, the other one is left with a pointer to something that no longer exists.
And the moral of the story -- use std::vector
.