talking about C++. Let's say I have an array of pointers to objects.In position Array[6] for example,I want to replace the object pointed by, with another of the same type. Which is the wisest way?
1.
delete Array[6];
Array[6]=new Object(...);
2.
Array[6]=NULL;
Array[6]=new Object(...);
3.
Array[6]=new Object(...);
Or something else I'm missing.Waiting for advice,thank you!!
EDIT:
question:
Do you want to delete the object pointed to by Array[6]? If so, do delete Array[6];. If not, don't delete Array[6];. I'm not sure what there is to be confused about there.
answer: Yes,it's what you've mentioned that I want. I want the object pointed by Array[6] to "disappear" and make a new one there. My other problem: I want to delete some objects of the Array in a function, but in another I want to access them so I have to check. Which will be my check? Maybe: if (Array[i]==NULL){..} or is it wrong since I have not "NULLed" it?