Question
This is a c++ problem, please help me write both Matrix.cpp and main.cpp file Implement a class Matrix( Matrix is of type double not
This is a c++ problem, please help me write both Matrix.cpp and main.cpp file
Implement a class Matrix( Matrix is of type "double " not int)
The Matrix.h header file is provide with member function and variable
Write the Matrix.cpp file where you'll defne each function clearly with comment next to the code
Everything in Matrix.cpp should be written according to informations inside Matrix.h, please do not attempt to change"void setData(int, int, double)" function, it's already written
Finally write a main function to test the above program
Notice: this is an obeject oriented on Matrix implementation in C++
-------------------------------------------------------------Matrix.h----------------------------------------------------------------------
#ifndef MATRIX_H
#define MATRIX_H
#include
using namespace std;
class Matrix {
private:
double ** data; // A two-dimensional double matrix
int row; // save data row
int col; // save data col
void setUp(int, int); // utility function, Set row and col value
public:
// default constructor, No argument passed, set it to 2*2 double data matrix with all values been 0
Matrix();
// constructor, set matrix size
Matrix(int, int);
// constructor, Save the incoming one-dimensional array as a two-dimensional array into data
Matrix(int, int, double [], int);
// copy constructor
Matrix(const Matrix &);
// destructor, clean up data
~Matrix();
void setData(int, int, double); // set each position (r,c)its with a data value
int getRow() const; // return private member: row
int getCol() const; // return private member: col
double getData(int, int) const; // Get value inserted in position (r,c) of matrix
Matrix add(const Matrix &); // Add two matrices, return the sum
Matrix multiply(const Matrix &);//Multiply two matrices, return the product
Matrix transpose(const Matrix &);// Transpose a matrix and return its transpose
void displayData() {// Print matrix data (Dont modify)
for (int i = 0;i for (int j = 0;j cout< } cout<<""< } } }; #endif
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