Matrix &Matrix::operator =
(const Matrix &m) {
if (this == &m) {
// avoid self-assignment
return *this;
} else {
if (dx != m.dx || dy != m.dy) {
this->~Matrix();
dx = m.dx; dy = m.dy;
allocArrays();
}
for (int i = 0; i < dx; i++) {
for (int j = 0; j < dy; j++) {
p[i][j] = m.p[i][j];
}
}
return *this;
}