So I have this array of pointers
image* [] myArray;
And I copy the objects in the array into a new, larger array.
for (int i=0; i<maxObjects; i++){
newArray[i] = myImages[i];
}
for (int i=maxObjects; i<newMaxObjects; i++){
newArray[i] = NULL;
}
The point of this is to resize my array. Then I delete myArray:
delete [] myArray;
Which, I presume deletes the objects from the array, as well as the pointer to those objects. Now I want to declare myArray again
image* [] myArray;
and set this to point to my new, larger array.
myArray = newArray;
This is where I get lost: now I've got two pointers to the same array. myArray points to the same thing as newArray, right? Or, am i wrong, and myArray now points to newArray (the pointer), which points to the object I want?
My main questions: How do I delete the temporary pointer myArray without deleting the data it points to? Also, how do I assign the myArray pointer directly to the data, rather than pointing to another pointer? Am I doing it right or is there a better way to do what I'm doing?