哪位能帮我解释一下这个代码哪里出错了!
//重载+,<<,>>运算符,计算二维数组相加。
#include<iostream>
using namespace std;
class Mat
{
public:
friend Mat operator+(Mat& a, Mat& b);
friend istream operator>>(istream& in, Mat& a);
friend ostream operator<<(ostream& cout, Mat& a);
Mat();
private:
int mat[2][3];
};
Mat::Mat()
{
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
mat[i][j] = 0;
}
istream operator>>(istream& in, Mat& m)
{
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
{
cin >> m.mat[i][j];
};
return cin;
}
ostream operator<<(ostream& cout, Mat& m)
{
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
{
cout << m.mat[i][j];
};
return cout;
}
Mat operator+(Mat& a, Mat& b)
{
Mat n;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
{
n.mat[i][j] = a.mat[i][j] + b.mat[i][j];
}
return n;
}
int main()
{
Mat a, b, c;
cin >> a;
cin >> b;
cout << "a=" << a;
cout << "b=" << b;
c = a + b;
cout << "c=" << c;
system("pause");
return 0;
}