Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

What is meant by decentralisation of authority ?

Answered: 1 week ago

Question

Briefly explain the qualities of an able supervisor

Answered: 1 week ago

Question

Define policy making?

Answered: 1 week ago

Question

Define co-ordination?

Answered: 1 week ago