Q#2 Write a program that templates the class Matrix. The Matrix class should have the following data and member function

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Q#2 Write a program that templates the class Matrix. The Matrix class should have the following data and member function

Post by answerhappygod »

Q 2 Write A Program That Templates The Class Matrix The Matrix Class Should Have The Following Data And Member Function 1
Q 2 Write A Program That Templates The Class Matrix The Matrix Class Should Have The Following Data And Member Function 1 (73.65 KiB) Viewed 65 times
Q#2 Write a program that templates the class Matrix. The Matrix class should have the following data and member functions: • Mrows & N columns • Pointer to array of pointers that stores each row on the heap via one of the pointers in the array of pointers • Default constructor • Parametrized constructor that sets the values of M and N and inits all elements to Value • Destructor • Copy constructor .getRowSize() & getColSize() • Overloaded assignment operator=() o If the row/col of the target matrix is not equal to row/col of destination matrix, print failure message and exit function • Overloaded operator+() that allows two congruent matrices to be added (add the destination elements to the corresponding target elements producing a resultant matrix of size (MN) • friend overloaded function operator<<( ) that prints out matrix in elegant format • After creating a working class for int, template your function. • Instantiate the case of a float matrix for the following cases: Matrix A(M=8, N=8, Value=5.0) and Matrix B(M==8, N=8, Value = 10.0) • Increment each element of Matrix A and Matrix B by i*Row#, where i is the row number • Add matrix A+B and assign it to matrix R(M=8, N=8, Value=0) • Output Matrix A, B and R Data Structures & C++
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply