#include
using namespace std;
int i,j;
class matrix
{
public: int row,column;
int **m;
friend istream& operator>>(istream& input,matrix& ma);
friend ostream& operator<<(ostream& output,matrix& ma);
matrix()
{
row=3;
column=3;
m = (int **)malloc(row * sizeof(int *));
for (i=0; i
m[i] = (int *)malloc(column * sizeof(int));
}
~matrix()
{
for (int i=0; i
free(m[i]);
free(m);
}
int* operator[](int) const;
matrix& operator--(int);
const matrix& operator-(const matrix&);
};
istream& operator>>(istream& input,matrix& ma)
{
for(i=0;i
for(j=0;j
input>>ma[i][j];
return input;
}
ostream& operator<<(ostream& output,matrix& ma)
{
for(i=0;i
for(j=0;j
output<
return output;
}
int* matrix::operator[](const int i) const
{
return this->m[i];
}
const matrix& matrix::operator-(const matrix& rhs)
{
for(i=0;i
for(j=0;j
this->operator[](i)[j]-=rhs.operator...
return *this;
}
matrix& matrix::operator--(int)
{
for(i=0;i
for(j=0;j
m[i][j]=m[i][j]-1;
return *this;
}
int main()
{
matrix m1,m2;
cout<<"Enter the value of 1st matrix";
cin>>m1;
cout<
cout<<"Enter the value of 2nd matrix";
cin>>m2;
cout<
m1-m2;
m1--;
getch();
return 0;
}
#include
#include
using namespace std;
int i,j;
class matrix
{
public:int row,column;
int **m;
friend istream& operator>>(istream& input,matrix& ma);
friend ostream& operator<<(ostream& output,matrix& ma);
matrix()
{
row=3;
column=3;
int **m = (int **)malloc(row * sizeof(int *));
for (i=0; i
m[i] = (int *)malloc(column * sizeof(int));
}
~matrix()
{
}
void operator--();
void operator-();
};
friend istream& operator>>(istream& input,const matrix& ma)
{
for(i=0;i
for(j=0;j
input>>ma[i][j];
return input;
}
friend ostream& operator<<(ostream& output,matrix& ma)
{
for(i=0;i
for(j=0;j
output<
return output;
}
void matrix::operator-(matrix x)
{
matrix t;
for(i=0;i
for(j=0;j
t.m[i][j]=m[i][j]+x.m[i][j];
cout<
}
void matrix::operator--()
{
for(i=0;i
for(j=0;j
m[i][j]=m[i][j]-1;
}
main()
{
matrix m1,m2;
cout<<"Enter the value of 1st matrix";
cin>>m1;
cout<
cout<<"Enter the value of 2nd matrix";
cin>>m2;
cout<
m1-m2;
m1-;
getch();
}