Question
> < In this project you will be defining a Template Matrix class in C++ and equip the class with a few matrix operations. If
><>< In this project you will be defining a Template Matrix class in C++ and equip the class with a few matrix operations. If the code does not compile no credit is given. The code must compile, and the main function execute successfully. The Matrix class must have the following private data members at least: 1. A variable to represent rows for the number of rows of the matrix 2. A variable column for the number of columns of the matrix 3. A pointer variable data to point to the matrix data. The Matrix class must also have the following member functions. 1. A default constructor this constructor initializes the row and column of the matrix to 3, then dynamically allocates memory for the elements of the matrix. The constructor also initializes the Matrix elements to random integers between 0 and 10. 2. A constructor with parameters - The parameters to the constructor are used to initialize the row and column variables. This constructor dynamically allocates memory for the elements of the matrix. The constructor also initializes the Matrix elements to random integers between 0 and 10. 3. A correct destructor. 4. A method called display() that displays the matrix in proper row/column form. 5. The method getElement(int i, int j) that will return the (i,j) element in the matrix. Include exception handling with object out_of_range for the case when i or j or both are out of bounds 6. The method setElement ( int i, int j, int value) that set the (i,j) element of the matrix to the value. Include exception handling with object out_of_range for the case when i or j or both are out of bounds. 7. The method for the addition of one matric object to another add(Matrix a) that receives a Matrix object a and adds it to the implicit object and returns another Matrix object. Include exceptions if matrices cannot be added ( e.g. in the case of incompatible types or dimensions) 8. The method multiply multiply( Matrix a) that receives a Matrix object and multiplies it to the implicit object and returns another Matrix object. Include exceptions if matrices cannot be multiplies (incompatible dimensions). An algorithm for matrix multiplication is given on page 205 of your textbook. 9. Overload the out stream operator << for the Matrix class to display a Matrix Object 10. Overload the in stream operator >> for the Matrix class to receive elements for a Matrix object. 11. Make proper use of const and references. Write a main() method to text the Matrix class. The main() method must include: 1. Declare two 3x3 matrices. 2. Test setElement() and getElement() methods 3. Test the exceptions by using invalid parameters 4. Use the operator <
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started