Write a C++ program that uses class Matrix for dealing with the square matrices (n x n tables of integers). The class constructor has to create a dynamic nxn matrix for n passed as a parameter. Supply the class with a copy constructor. Two overloaded operators + and * have to be implemented for adding and multiplying two matrices, respectively. The sum and product of two matrices A and B are square matrices with the entries defined as follows:
Cij = Aij + Bij, i=1,...,n, j=1,...,n
Cij = Ai1*B1j + Ai2*B2j + ... + Ain*Bnj
The matrix elements have to be initialized by the method setMatrix() that reads the matrix elements from the standard input from a file by using the redirection of input. The file have to contain 2·n2 matrix elements (for two nxn matrices) separated by spaces corresponding to the row-by-row scan of each matrix. The program must figure out the matrix dimension n automatically (n must not be a part of input).© BrainMass Inc. brainmass.com March 21, 2019, 5:59 pm ad1c9bdddf
This solution provides a C++ program that uses a class matrix for dealing with the square matrices.