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
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
---------------------------------------------------------------------------------------
//matrixTest.cpp file
#include ------------------------ //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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started