Question: C++ Overloading I need help designing a Matrix class that can support certain matrix operations. - Create a myMatrix class to store M rows and

C++ Overloading

I need help designing a Matrix class that can support certain matrix operations.

- Create a myMatrix class to store M rows and N columns (use dynamic arrays). - overload + and - operators to add and subract matching myMatrix instances. - overload * operator multiply two matching myMatrix instances - overload = operator. - overload << for printing matrices. - Implement constructors, (i) zero matrix (ii) random matrix and (iii) allOne matrix of the given size.

main.cpp shall support the following statements:

M = 4; N = 5; myMatrix matrix1(M, N); //sets a zero matrix myMatrix matrix2(4, 5, "random"); myMatrix matrix3(4, 5, "allOne");

cout << "matrix1: " << matrix1 << endl; cout << "matrix2: " << matrix2 << endl; cout << "matrix1 + matrix2 = " << matrix1 + matrix2 << endl; matrix3 = matrix1 + matrix2; cout << "matrix3: " << matrix3 << endl;

myMatrix matrix4(5, 4, "allOne"); cout << "matrix3 * matrix4 = " << matrix3 * matrix4 << endl;

Note: Must have a header for the design so that there will 3 files at the end:

- main.cpp

- mymatrix.cpp

- mymatrix.h

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The task involves designing a myMatrix class in C to handle matrix operations usi... View full answer

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 Databases Questions!