Question: Question: Write a C++ program that has following Template class: template Matrix - ** matrix1: M_type - ** matrix2: M_type -rows; int -cols: int +Matrix():

 Question: Write a C++ program that has following Template class: templateMatrix- ** matrix1: M_type - ** matrix2: M_type -rows; int -cols: int+Matrix(): Default Constructor +Matrix(const int &row, const int &col): Overloaded Constructor +-Matrix():destructor +printMatrix10): void +printMatrix20): void +addMatrix(): void +findElements(): void +operator[ ](const int&index): M_type*& +getRow(): int +getColl): int +setRow(int) +setCol(int) Class Variables: M_type **matrix1:

Question: Write a C++ program that has following Template class: templateMatrix - ** matrix1: M_type - ** matrix2: M_type -rows; int -cols: int +Matrix(): Default Constructor +Matrix(const int &row, const int &col): Overloaded Constructor +-Matrix(): destructor +printMatrix10): void +printMatrix20): void +addMatrix(): void +findElements(): void +operator[ ](const int &index): M_type*& +getRow(): int +getColl): int +setRow(int) +setCol(int) Class Variables: M_type **matrix1: 2 dimensional dynamic array for first matrix. M_type **matrix2: 2 dimensional dynamic array for second matrix. Int rows: Number of rows for matrices. Int cols: Number of columns for matrices. Class Functions: Matrix(): This is default constructor of Matrix class. Matrix(int row, int col): Overloaded constructor of Matrix class. It takes integer row and column values as parameters. -Matrix(): This is destructor class that should free memory by deleting dynamic arrays of Matrix class. void findElements(M_type value): This function let user find any element in both matrices. Function takes M_type value as a parameter and finds the element in the matrices. Then, prints the index numbers for each occurrence and total frequency that are found in both matrices. void addMatrix(): This functions simply adds two matrices of Matrix class. Then, prints the added matrix to the screen. void inputMatrix1(): In this function, you should get inputs from the user for elements of first matrix. void inputMatrix2(): In this function, you should get inputs from the user for elements of second matrix. int getRow(): This function returns number of rows for the matrices. int getCol(): This function returns number of columns for the matrices. void setRow(int row): This function changes number of rows for the matrices. void setCol(int col): This function changes number of columns for the matrices. void printMatrix1(): This function prints the elements of first matrix. void printMatrix2(): This function prints the elements of second matrix. M_type*& operator[ ](const int &index): This is an overloaded operator for U operator. It should return the value according to the given indices. You should use Assert() function to check that index>=0 and index

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