Question: With the givin MatrixTest.cpp and the makefile and the three matrix text files. Write a Matrix.cpp and Matrix.h file so that the MatrixTest file will

With the givin MatrixTest.cpp and the makefile and the three matrix text files. Write a Matrix.cpp and Matrix.h file so that the MatrixTest file will output the following. The max size for a matrix is 9X9. You must implement your Matrix class using static arrays. You can not hard code your answer.

| 13 4 2 1|

| 3 12 5 4|

| 4 8 6 11|

| 13 4 2 1|

| 3 12 5 5|

| 4 8 6 11|

| 13 4 2 1 3 2|

| 1 2 54 3 2 2|

| 11 32 2 6 5 4|

| 3 1 8 6 12 33|

1

0

| 26 8 4 2|

| 6 24 10 8|

| 8 16 12 22|

| 26 8 4 2|

| 6 24 10 9|

| 8 16 12 22|

| 13 4 2 1|

| 3 12 5 4|

| 4 8 6 11|

| 198 125 254 43 69 75|

| 118 200 696 93 106 182|

| 159 235 540 130 190 411|

| 0 0 0 0 0 0 0 0 0|

| 0 0 0 0 0 0 0 0 0|

| 0 0 0 0 0 0 0 0 0|

| 0 0 0 0 0 0 0 0 0|

| 0 0 0 0 0 0 0 0 0|

| 0 0 0 0 0 0 0 0 0|

| 0 0 0 0 0 0 0 0 0|

| 0 0 0 0 0 0 0 0 0|

| 0 0 0 0 0 0 0 0 0 |

---------------------------------------------

//Matrix.h file

#ifndef MATRIX_H #define MATRIX_H #include #include #include #include #include

using namespace std;

class Matrix { public: Matrix(); Matrix(int new_num_rows, int new_num_cols); Matrix operator+ (const Matrix& M2) const; void print(ofstream& fout) const;

private: int num_rows; int num_cols; vector > values; }; #endif

---------------------------------------------------------------------------------------

//matrixTest.cpp file

#include #include "Matrix.h" using namespace std; int main(){ Matrix m1("m1.txt"); Matrix m2("m2.txt"); Matrix m3("m3.txt"); cout<<(m1); cout<<(m2); cout <

------------------------

//make file

VERSION = -std=c++14

CFLAGS = -pedantic -Wall -Wextra $(VERSION) $(DEBUG)

LFLAGS = -Wall $(VERSION) $(DEBUG)

INCS = Matrix.h

SRCS = Matrix.cpp \

MatrixTest.cpp

OBJS = $(SRCS:.cpp=.o)

EXEC = MatrixTest

all: $(SRCS) $(EXEC)

# To make an object from source

#.cpp.o:

%.o:%.cpp $(INCS)

$(CXX) $(CFLAGS) -c $< -o $@

$(EXEC): $(OBJS)

$(CXX) $(LFLAGS) $(OBJS) -o $@

# for Windows

clean:

del *.o $(EXEC).exe

@echo clean done

# for UNIX / Linux

#remove:

# m -f *.o $(EXEC)

# @echo clean done

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!