How would I go about destroying a dynamic array of arbitrary size, dimensions, and type?
Will delete[] automatically go down the levels of a two dimensional array or just delete the first level of pointers so the program need to manually iterate over each array level?
Ideally I need a single command (for use in a template class) that will destroy one to four dimensional arrays. It would also work if there is a way to check the number of dimensions of an array.
I am using dymanic arrays such as double* ar = new double[100];
if you instanciate the 2 dimensional array like
new int[10][20]thedelete[]will destroy all the array, but if you created it iterating likemyarray[i] = new int[20]so you will have to iterate again to destroy each dimension.If you are not sure about how to destroy the array I would recoment you to use the STL vector.