Question: Need help c++. Need help with parts 6 and 7. See photos for instructions. My code for the other parts is pasted below. Please make
Need help c++. Need help with parts 6 and 7. See photos for instructions. My code for the other parts is pasted below. Please make parts 6 and 7 work with my code. Due at 11:30 pm eastern us time tonight. Thanks.
#include
using namespace std;
class Matrix //class matrix
{
private: //private variables
int row, col;
double *m[10];
public:
Matrix(int r , int c) //constructor for row col and matrix initialization
{
row=r;
col=c;
for(int i=0;i
m[i]= new double[col];
}
/* Matrix(Matrix const &ma);*/
friend ostream & operator
friend istream & operator >> (istream &in, Matrix &c); //input stream function
void operator=(Matrix &x); //operator overloding functions =
void operator+=(Matrix &x); //operator overloding functions +=
void operator-=(Matrix &x); //operator overloding functions -=
void operator--(); //operator overloding functions --
void operator++(); //operator overloding functions ++
};
void Matrix :: operator=(Matrix &x) //operator overloding functions = defination
{
for(int i=0;i
for(int j=0;j
m[i][j]=x.m[i][j];
}
void Matrix :: operator++() //operator overloding functions ++ defination
{
for(int i=0;i
for(int j=0;j
m[i][j]++;
}
void Matrix :: operator--()//operator overloding functions -- defination
{
for(int i=0;i
for(int j=0;j
m[i][j]--;
}
void Matrix ::operator+=(Matrix &x) //operator overloding functions += defination
{
for(int i=0;i
for(int j=0;j
m[i][j]+=x.m[i][j];
}
void Matrix ::operator-=(Matrix &x) //operator overloding functions -= defination
{
for(int i=0;i
for(int j=0;j
m[i][j]-=x.m[i][j];
}
/*Matrix::Matrix(Matrix const &ma)
{
row=ma.row;
col=ma.col;
for(int i=0;i
for(int j=0;j
m[i][j]=ma.m[i][j];
} */
ostream & operator
{
for(int i=0;i
{
for(int j=0;j
{
out
cout
}
cout
}
return out;
}
istream & operator >> (istream &in, Matrix &c)//operator overloding functions >> defination
{
cout
for(int i=0;i
for(int j=0;j
in >> c.m[i][j];
return in;
}
int main() //main program
{
Matrix A(3,3),B(A),C(A),D(A); //object declaration and call copy constructor
cin >> A; //take input through ifstream
cout
cout
B=A; //= operator over loading
C=A;
D=A;
cout
cout
B+=A; //+= operator loading
cout
cout
cout
C-=D; //-= operator loading
cout
++D; //++ operator loading
cout
cout
--D; //-- operator loading
cout
Project 2-Matrix Class Operator Overloading Fall 2017 Due: 11/13 Monday 11:30 PM For this homework exercise you will be exploring the implementation of matrix multiplication using C There are third party libraries that provide matrix multiplication, but for this homework you will be implementing your own class object and overloading some C++ operators to achieve matrix multiplication. 1. [10pts] Create a custom class called Matrix a. Private Members i. int rows; ii. int cols ili. double data; b. Provide NO default constructor c. Constructor i. Matrix(int, int) takes rows and cols ii. Inside constructor allocate and initialize data. d. Destructor i. Matrix() ii. Inside destructor delete memory allocation of data completely 2. [10pts] Overload Copy constructor 3. [10pts] Overload > a. For input, user inputs the values of the matrix in row then column format i. HINT: using a space you can separate column data and enter for row b. For output, use tab and return line to create a matrix-like output 4. (10pts] Overload the assignment operator () cout
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
