Ошибка отладочного утверждения BLOCK_TYPE_IS_VALID (pHead-> nblockuse) из деконструктора

Я совершенно потерян прямо сейчас. Я сделал векторный класс. Все работает так, как мне бы хотелось, чтобы все работало, до конца. Когда вызывается деструктор, я получаю сообщение об ошибке: Ошибка отладки BLOCK_TYPE_IS_VALID (pHead->nblockuse). Я'я видел довольно много вопросов, подобных этому, на SO, но то, что я пробовал, нет работал.

часть .ч.

private:
    int* _myArray;
    int _size;
    int _capacity;

#include "File.h"

 const string RETURN_CARRIAGE_STR = "\n";
 const string SIZE_STR = "Size ";
 const string CAPACITY_STR = "Capacity ";
 const int INITIAL_CAPACITY = 2;

 int main(void)
{
cout < "\nCreating a vector Sam of size 4.";
MyVector sam( 4 );

cout < "\nPush 12 values into the vector.";
for (int i = 0; i < 12; i++)
    sam.push_back(i);

cout < "\nHere is sam: ";
cout < sam;
cout < "\n---------------\n";

    cout < "\nCreating a vector Joe of size 4.";
MyVector joe( 4 );
cout < "\nPush 6 values into the vector.";
for (int i = 0; i < 6; i++)
    joe.push_back(i * 3);

cout < "\nHere is joe: ";
cout < joe;
cout < "\n---------------\n";

cout < "\nTest the overloaded assignment operator \"joe = sam\": ";
joe = sam;


cout < "\nHere is sam: ";
cout < sam;
cout < "\n---------------\n";

cout < "\nHere is joe: ";
cout < joe;
cout < "\n---------------\n";

// pass a copy of sam by value
PrintV(sam);

cout < endl;
system("PAUSE");
 }

 void PrintV(MyVector v)
 {
cout < "\n--------------------\n";
cout < "Printing a copy of a vector\n";
cout < v;
 }

 // Default Constructor
 MyVector::MyVector()
 {
_myArray = new int[INITIAL_CAPACITY];
_size = 0;
_capacity = INITIAL_CAPACITY;
//cout < "Default Constructor" < endl;
 }

 MyVector::MyVector(int aSize)
 {
_myArray = new int[aSize];
_size = 0;
_capacity = aSize;

//cout < "Parameterized Constructor" < endl;
 }

 MyVector::~MyVector()
 {
if(_myArray != NULL)
{
    delete[] this->_myArray; //  --------------This is where I get an error
    this->_myArray = NULL;
}

//cout < "Destructor" < endl;
 }


 int MyVector::GetSize()
 {
return _size;
//cout < " size";
 }

 int MyVector::GetCapacity()
 {
return _capacity;
//cout < _capacity < " capacity" < endl;
 }

 void MyVector::Clear()
 {
int* resize_arr = new int[INITIAL_CAPACITY];
delete[] _myArray;
_myArray = resize_arr;
_capacity = INITIAL_CAPACITY - 1;
_size = 0;
 }

 void MyVector::push_back(int newValue)
 {
if(_size < _capacity)
{
    _myArray[_size] = newValue;
}
else  {
    int* resize_arr = new int[_capacity*2];
    for(int i = 0; i 

Ответы на вопрос(2)

Ваш ответ на вопрос