Define a Class for Matrix Manipulation

  1. We would like to design a class CMatrix to handle 3x3 matrices. In general, the size of a matrix should be m by n, where m is not necessarily equal to n. However, let us only consider the fixed-size matrices at this stage, so that it is easy for you to start with.
  2. A matrix has the following private data members:
  3. A matrix has the following public member functions:
    1. Constructor:
      • If no argument is passed to the constructor, it assigns every entry in the matrix to be 0.
      • If an integer n is passed to the constructor, it assigns n to every entry.
    2. Get(i,j): returns the value of entry[i][j], where 0<=i<=2, 0<=j<=2.
    3. Set(i,j,n): assigns value n to entry[i][j].
    4. Print(): print out the 3x3 matrix. Note that integers in a column should be right-justified.

Test your class definition with this main program. Save your class definition (including the implementation of member functions) in "matrix.h" and compile the program with "g++ matrix-1.cpp". The running result should look like:

 1 1 1
 1 1 1
 1 1 1
  1  1  1
  1 10  1
  1  1  1
   2   2   2
   2   2   2
   2   2 100