Hi there,
I'm writing a C++ app which deals with dynamic allocated memory, a matrix to be more specific.
My real doubt is: when I use delete[], it does dealloc a column/line of the matrix, or it does dealloc the whole matrix?
int** matrix = newint*[5];
for(unsignedint i = 0; i < 5; ++i) {
matrix[i] = newint[5];
}
//matrix is a 5x5 matrix
//if we call delete[] matrix; here, we will *only* delete the first element of each array,
//and miss the other 4, so we need to call it like this:
for(unsignedint i = 0; i < 5; ++i) {
delete[] matrix[i];
}
delete[] matrix;