以下程序有几个错误:建立一个二维数组类Douary,使该类中有以下数据成员、成员函数及友员函数,完成矩阵的输入、输出、加、减、相等判断等操作。 希望高人指点
#include <iostream.h>class Douary{public: Douary(int m=0, int n=0);//构造函数:用于建立动态数组存放m行n列的二维数组(矩阵)元素,并将该数组元素初始化为 ~Douary(); //析构函数:用于释放动态数组所占用的存储空间。 friend istream &operator>>(istream &input, Douary &d);//重载运算符“>>”输入二维数组,其中d为Dousry类对象; friend ostream &operator<<(ostream &output, Douary &d);//重载运算符“<<”以m行n列矩阵的形式输出二维数组,其中d为Douary类对象。// friend Douary &operator+(const Douary &d1,const Douary &d2);//两个矩阵相加,规则:对应位置上的元素相加// friend Douary &operator-(const Douary &d1,const Douary &d2);//两个矩阵相减,规则:对应位置上的元素相减// bool &operator==(const Douary &d);//判断两个矩阵是否相等,即对应位置上的所有元素是否相等private: int * Array; //Array 为动态数组指针。 int row; //row 为二维数组的行数。 int col; //col 为二维数组的列数。}Douary::Douary(int m, int n)//构造函数:用于建立动态数组存放m行n列的二维数组(矩阵)元素,并将该数组元素初始化为{ row=m; col=n;}istream &operator>>(istream &input, Douary &d)//重载运算符“>>”输入二维数组,其中d为Dousry类对象;{ input>>d.row >>d.col ; d.Array =new int[d.row][d.col]; return input;}ostream &operator<<(ostream &output, Douary &d)//重载运算符“<<”以m行n列矩阵的形式输出二维数组,其中d为Douary类对象。{ output<<d.row <<'/'<<d.col <<endl; return output;}int main(){ Douary d1(2,3),d2(2,3) cout<<"输入d1:"<<endl; cin>>d1; cout<<"输入d2:"<<endl; cin>>d2; coutt<<"d1="<<endl; cout<<d1; coutt<<"d2="<<endl; cout<<d2; coutt<<"d1+d2="<<endl; cout<<(d1+d2); coutt<<"d1-d2="<<endl; cout<<(d1-d2); cout<<"d1"<<((d1==d2)?"==":"!=")<<"d2"<<endl; return 0;}