I have allocated and array of Objects
Objects *array = new Objects[N];
How should I delete this array? Just
delete[] array
As a general rule you should delete
/delete[]
exactly those things that you allocated with new
/new[]
. In this case you have one allocation with new[]
, so you should use one call to delete[]
to free that allocated thing again.
That the delete
s in the for-loop won't compile is also a good indication that they are not the right way to do it.