Well i am trying to add some numbers to an array, if the array is full the program creates a new, bigger array, and when i try to erase the old one i'm getting Heap Corruption Error. Please help.
Number** IntArrayList::CreateNewArray(Number** arr)
{
m_ArraySize *= 2;
Number** newArray = new Number*[m_ArraySize];
for(int i = 0 ; i < m_Size ; i++ )/// creating new array.
newArray[i] = m_Arr[i];
//for(int i = 0 ; i < m_Size ; i++)/// delete old array.// this part doesnt' work at all
// delete m_Arr[i];///
///delete m_Arr;////
return newArray;
}
I think that the problem is that the new allocated array was not initialized by NULL(s). So its elements starting from m_Size have undefined values.
Also in member function add you forgot to increase m_Size