Let's say I have the array:
Geometry* shapes[MAX_SIZE];
And then I fill the array like that:
for (int i = 0; i < MAX_SIZE; ++i)
{
shapes[i] = new Geometry;
}
Will delete [] shapes; do the job or I have to loop through the array and delete one by one :
for (int i = 0; i < MAX_SIZE; ++i)
{
delete shapes[i];
}
I think I have to loop and delete individually each pointer, because delete [] calls the destructors of the objects in the array which doesn't mean that the memory will be freed. But I need a confirmation from someone more experienced.
std::unique_ptr<Geometry> shapes[MAX_SIZE]and not have to do anything. But in your case you'll need the second.