C++ code for all operations of the matrix