Question: Matrix sum in the first two rows is wrong. Can you correct it? It is C++ question. #include #include using namespace std; template class Matrix

Matrix sum in the first two rows is wrong. Can you correct it? It is C++ question.

#include #include using namespace std; template

class Matrix {

T **mtr;

int loc = 4; public: Matrix() { mtr = new T*[loc]; for (int i = 0; i

}

}

friend istream& operator >>(istream &inp, Matrix &M) { for (int i = 0; i > M.mtr[i][j]; //if user enters 25 if (M.mtr[i][j] 25) { cout

} friend ostream& operator

Matrix operator +(Matrix const &B) { Matrix C;

for (int i = 0; i mtr[i][j] + B.mtr[i][j]; } } return C; }

Matrix operator-( Matrix const &B) { Matrix C; for (int i = 0; i mtr[i][j] - B.mtr[i][j]; } } return C; }

~Matrix() { delete mtr; cout

};

int main() { char ch;

cout>ch;

if(ch=='i' || ch=='I') { Matrix A; Matrix B; char op; cout > A; cout > B; cout > op; MatrixC; if (op == '+') { C = A + B; cout A; Matrix B;

char op; cout > A; cout > B; cout > op; MatrixC; if (op == '+') { C = A + B; cout

OUTPUT

Matrix sum in the first two rows is wrong. Can you correct

i use Int 'd' use Double Enter choice : i Enter inp Matrix A: 3 2 5 15 0 1 61 2 2 1 1 8 4 3 6 Enter inp Matrix B: 2 1 2 7 0 1 8 0 2 2 1 1 6 2 2 3 Choose optrn (+/-): + Matrix has been dest. sum Matrix: 2031952 0 2054912 0 2054912 0 2057120 0 4 4 2 2 14 6 5 9 Process exited after 40.37 seconds with return value 3221226356 Irow

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!