Code:
delete [] matrix; delete [] matrix[0];
obviously wrong because you are using the matrix after removing it.
delete [] matrix[0]; delete [] matrix;
is correct, but I cannot guarantee that the code as a whole does something reasonable.
Please note that you should not delete matrix [1] and matrix [2], since they are only copies of matrix [0]. A rule of thumb is that you must have the same number of calls to delete, since you have calls for new ones.
anon
source share