C++ 编一个程序,考试中。

来源:百度知道 编辑:UC知道 时间:2024/05/31 07:16:01
一个程序,用成员函数重载运算符+和-。将两个二维数组相加和相减,要求第一个二维数组的值由构造函数设置,另一个二维数组的值由键盘输入。 急!!!!

#include<iostream>

using namespace std;

class matrix
{
private:
double *p;
int m,n;
double getdouble(void)
{
double a;
while(1)
{
cin >> a;
if(cin)
break;
cin.clear();
cin.ignore(1024,'\n');
cout<<"Error input, please input an double format number!"<<endl;
}
return a;
}
public:
matrix(const double *a,const int b,const int c)
{
p=new double[b*c];
m=b;
n=c;
memmove(p,a,sizeof(double)*b*c);
}
matrix(const char *a,const int