I just can't get used to C++ syntax yet..
any intuitive explanation on
//delete [] foo
// and
//delete foo[]
would be very appreciated.
to be more precise, let's say I have
int** foo = new int*[50]
for (int index = 0; index<50;++index)
foo[index] = new int[50]
//foo = 2d 50x50 matrix
//now lets say i want to deallocate the memory of this matrix
for (index index=0;index<50;++index)
delete[] foo[index]
delete[] foo
now I know I need to delete all the "inner" pointers that I've allocated before and then delete the pointer to a pointer.
but, my question is, what IS the []
after the delete used for? i mean if you leave it empty all the time why is even there? does it get any parameter some times? or we always just delete[] foo
?