I'm not sure if the word Reorganizing is the correct term, but its the only way I can describe what I'm looking for.
If I have an array of say, Cats, like so:
CAT *myCats[99];
myCats[0] = new CAT;
myCats[1] = new CAT;
myCats[2] = new CAT;
myCats[3] = new CAT;
myCats[4] = new CAT;
myCats[5] = new CAT;
At one point in time, lets say myCats[3] gets deleted:
delete myCats[3];
now I have the following:
myCats[0]
myCats[1]
myCats[2]
myCats[4]
myCats[5]
Is there an easy way to reorganize the array so that it moves 4->3 and 5->4, essentially filling in the gaps?
myCats[0]
myCats[1]
myCats[2]
myCats[3]
myCats[4]
Is the best way to accomplish this, to essentially iterate through the array and determining that if a element is empty/missing, I just need to move the next existing element into its place? How would I do this? How would I determine if the Cat element at any point in the array exists? Or is there a more simple pre-determined method for accomplishing what I need?
Sorry if the example and syntax is a little off. I'm new to C++.
UPDATE
Thanks for the quick suggestions. Looks like Vectors are the way to go. I always forget about Vectors. In the front of my mind, a Vector is just a container that holds an x, y and z value :-)