I have the code that goes bellow. I use Visual Studio and try to debug my program.
During a program run I get an error: Debug Error! HEAP CORRUPTION DETECTED... CRT detected that the application wrote to memory after end of heap buffer.
What is wrong?
Thanks.
Code:
...
int _row;
int _col;
bool **_matrixArr;
...
BinaryMatrix::~BinaryMatrix() {
for (int i = 0; i < _row; i++) {
delete [] _matrixArr[i];
}
delete [] _matrixArr;
};
void BinaryMatrix::InitMatrixArray() {
bool **matrix = new bool*[_row];
for (int i = 0; i < _row; i++) {
matrix[i] = new bool[_col];
}
_matrixArr = matrix;
};
What is wrong?
Thanks.
Comment