In C++ FAQ, the [16.16] gives the following example,
void manipulateArray(unsigned nrows, unsigned ncols[])
{
typedef Fred* FredPtr;
FredPtr* matrix = new
What you're missing is the horribly evil indentation.
delete matrix[i-1];
happens once per loop iteration and deletes the nested arrays.
delete matrix
happens just one time after the loop completes and deletes the outer array.
Never write code like this in C++, use vector
instead.
The reason the deletes also exist in the catch is because if you catch an exception you're still responsible to clean up the memory you allocated.