#include<iostream>
#include<conio.h>
using namespace std;
class matrix
{
int m[3][2];
public:
matrix()
{
for(int i=0;i<3;i++)
for(int j=0;j<2;j++)
m[i][j]=0;
}
matrix(int a)
{
for(int i=0;i<3;i++)
for(int j=0;j<2;j++)
m[i][j]=a++;
}
matrix operator+(matrix b)
{
matrix t;
for(int i=0;i<3;i++)
for(int j=0;j<2;j++)
t.m[i][j]=m[i][j]+b.m[i][j];
return t;
}
void output();
};
void matrix::output()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<2;j++)
{
cout<<m[i][j]<<'\t';
}
cout<<endl;
}
}
void main()
{
matrix m1,m2(1),m3(7),m4;
m1.output();
m2.output();
m3.output();
m4=m2+m3;
m4.output();
getch();
}
No comments:
Post a Comment