>> for(int i=0; i<5; i++){
delete [] array[i] ;}
delete[] array;
second line should be delete array[i].
Yeah cheers for that meow, I was already aware of that, I was just interested as to why the explicit call to delete[] did not work as I thought it would. Indeed deleting each individual element does result in the destructor being called, as it should.
So I suppose I have answered my own question there. To delete 2D arrays, the syntax you mentioned should be used.
GRRRR I AM AN IDIOT ATM AND AM NOT THINKING CORRECTLY. OF COURSE 2D ARRAYS HAVE TO BE DELETED AS YOU HAVE MENTIONED !
ARGGHHHHHH
Main Topics
Browse All Topics





by: meow00Posted on 2003-12-11 at 11:19:54ID: 9922503
Hello try this
--
-----------
int main()
{
D** array = new D*[5];
for (int i = 0; i < 5; i++) {
array[i] = new D();
}
//delete array[1];
for(int i=0; i<5; i++){
delete [] array[i] ;}
delete[] array;
return 0;
}
--------------------------
since it is a two dimension array, you have to do it step by step.
meow ....