I'm trying to delete the memory first before allocate new memory, but i dont know how to make, and I have one problem when try to resize the matrix.
Matrix & operator=(const Matrix &B){
row = B.row;
col = B.col;
if (matrix==0){
matrix = new int*[row];
for (int i = 0; i < row; ++i)
matrix[i] = new int[col];
}
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
matrix[i][j] = B.matrix[i][j];
}
}
return *this;
}
For example (resize)
Matrix matrixA(1, 1);
Matrix matrixB(2, 2);
matrixA = matrixB;
Thank you & best regards