#include<iostream.h>
class base
{
public:
int a[2][2];
base(int a,int b,int c,int d);
base(){}
void input();
void show();
};
void base::show()
{ for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
cout<<a[i][j]<<endl;
}
base::base(int i,int b,int c,int d)
{
int* p=a[0];
*p=i; p++;
*p=b; p++;
*p=c; p++;
*p=d;
}
void base::input()
{
cin>>a[0][0]>>a[0][1]>>a[1][0]>>a[1][1];
cout<<endl;
}
base operator+(base x,base y)
{
base co;
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
co.a[i][j]=y.a[i][j]+x.a[i][j];
return co;
}
base operator-(base x,base y)
{
base co;
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
co.a[i][j]=x.a[i][j]-y.a[i][j];
return co;
}
int main()
{
base i(15,6,13,21),j,z;
cout<<"please input 4 number:"<<endl;
j.input();
z=i+j;
cout<<"i+j="<<endl;
z.show();
z=i-j;
cout<<"i-j="<<endl;
z.show();
return 0;
}
09-15
09-15