Original Post
What I'm doing is not strictly resizeing the array (I don't think that is possible. I have a set class and objects are stored in a dynamic array. The array is initialised in the set's constructor so when an item is inserted and there is no room left the array is doubled. CObject is part of a linked list with a pointer to next on the list. I have been attempting it like so: The aray has been initialised like so...
CObject< Type >* data = new CObject< Type >[ m_Size ];
but when the array is full we want to double the array...
CObject< Type >* data = new CObject< Type >[ m_Size*2 ];
for( int i=0; i<m_Size; i++ )
{
data = m_Data;
}
delete m_Data;
m_Data = data;
m_Size*=2;
The for loop copies all the data fine (although it looks like it is copying mem loc's instead of values). If I add a watch to data and m_Data I can see that before I have deleted m_Data, data's values are correct. However, once I delete m_Data the values in data (except the first on the list) all change as if they have been deleted. I've not a clue why this is happening. If anyone knows a better way to create a new dynamic array and copy the values over I'm all ears.