Question: in c + + 5 pts ] Write a MyMatrix class to represent a 2 x 2 matrix that has 4 private float members. There

in c++
5pts] Write a MyMatrix class to represent a 2x2 matrix that has 4 private float members. There are many ways you
can define these variables such as using an array or a vector. However, it is recommended that you define a single
variable for each of the four numbers such as:
a11 a12
a21 a22
2.[5pts] Add getters and setters for each private data member.
3.[5pts] Implement a constructor to set the data members to valid values when an object is created. You should
implement a single overloaded constructor to take zero to four inputs with default values.
4.[5pts] Implement a print method that prints the values of the matrix to the screen in the form: [a11, a12; a21, a22].
5.[20pts] Write a main program that unit tests the getters, setters, constructor and print methods of your MyMatrix
class. Add comments to your program for each test. Your main program should have a comment block above the
main function. Your program should have enough unit tests to prove that your methods work correctly.
6.[5pts] Implement a method to compute the matrix norm, i.e., the square root of the sum of squares of the matrix
elements. For example, if the Matrix object is A, then A.norm() returns the norm of the matrix. Add a comment block
for this function.
7.[5pts] Implement an add method that takes another MyMatrix object as the input parameter, performs the matrix
addition and stores the result in the matrix object. For example, if the Matrix object is A, then A.add(B) should
change the member variables of A to the result of A+B.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!