So we have the following code, which illustrates an "Array of pointers" (I think)
main() {
int *array[3];
int x = 10, y = 20, z = 30;
array[0] = &x;
array[1] = &y;
array[2] = &z;
return 0;
}
Now, let's say instead of int
s, they are a type of an object class that you have created.
So I want to remove a member from this array (i.e. to call its destructor by means of the delete keyword and have the object destroyed, but having the pointer remain fine.)
If my suspicions are correct, that isn't possible, and the only choice I have is to copy the contents of the array to a new array (except for the one(s) I want to delete) and then delete the previous array (as a whole with all of its elements) while I assign the new one to the pointer array
I would appreciate if someone could confirm or correct my suspicions, specially since the name "Array of pointers" is SO misleading. Thank you.