You can use a vector<vector<int>>
instead of p
, m
, and n
.
No need to manage memory (using new
and delete
) - the vector
class will take care of that.
BTW, your operator=
is pretty nasty.
Instead of replicating the allocated data pointed by p
, it copies the value of p
.
As a result, you will get two matrix
objects sharing the same data.
If you change one, then you essentially change the other.
If you deallocate one (dynamically or statically at the end of the scope in which it is allocated), then the other one will hold a pointer to an unallocated memory block.