c++矩阵的加法 #include#includeclass matrix{public:void setvalue();void display();matrix operator +(matrix &b);matrix();matrix(int m,int n);private:int M,N;double *array;};matrix::matrix(int m,int n){ array=NULL;M=m;N=n;array=new double[M*N];}mat
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/25 20:27:45
c++矩阵的加法 #include#includeclass matrix{public:void setvalue();void display();matrix operator +(matrix &b);matrix();matrix(int m,int n);private:int M,N;double *array;};matrix::matrix(int m,int n){ array=NULL;M=m;N=n;array=new double[M*N];}mat
c++矩阵的加法
#include
#include
class matrix
{
public:
void setvalue();
void display();
matrix operator +(matrix &b);
matrix();
matrix(int m,int n);
private:
int M,N;
double *array;
};
matrix::matrix(int m,int n)
{
array=NULL;
M=m;N=n;
array=new double[M*N];
}
matrix::matrix()
{
delete[]array;
}
matrix matrix::operator +(matrix &b)
{
matrix c(M,N);
for(int i=0;i
c++矩阵的加法 #include#includeclass matrix{public:void setvalue();void display();matrix operator +(matrix &b);matrix();matrix(int m,int n);private:int M,N;double *array;};matrix::matrix(int m,int n){ array=NULL;M=m;N=n;array=new double[M*N];}mat
#include
using namespace std;
class CMatrix
{
public:
CMatrix(unsigned long m,unsigned long n);
CMatrix(CMatrix& A); // COPY构造函数,必须要.
CMatrix(){_m=0;_n=0;_data=NULL;}//无参数构造函数,必须要.
CMatrix(){if(_data!=NULL)delete _data;}
void DisplayOnCMD();
bool SetCell(unsigned long x,unsigned long y,double data);
double GetCell(unsigned long x,unsigned long y);
unsigned long GetM(){return _m;}
unsigned long GetN(){return _n;}
CMatrix operator+(const CMatrix &A);
CMatrix operator=(const CMatrix &A);
private:
unsigned long _m,_n;
double* _data;
};
CMatrix::CMatrix(unsigned long m,unsigned long n)
{
_m=m;_n=n;
_data=new double[_m*_n];
for(int i=0;i