作业帮 > 综合 > 作业

矩阵类的设计,用C++,要求:定义矩阵类,包含行、列和矩阵数据元素;

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/05 22:35:52
矩阵类的设计,用C++,要求:定义矩阵类,包含行、列和矩阵数据元素;
最好是用到构造函数,重载函数等等,一定要有说明.很着急,明天交!1
要求至少设计以下各功能模块:
 输入矩阵
 输出矩阵
 矩阵的加法
 矩阵的乘法 \
只有一天的时间了!
我没有重载函数,只重载了运算符,你看看行不行.
这是头文件:
#ifndef MATRIX_H
#define MATRIX_H
#include
using std::cout;
using std::endl;
class Matrix{
public:
Matrix():row(0),column(0),m(0){}
Matrix(const Matrix& ma);
Matrix();
void setMatrix(int r,int c,double **ma);
int getRow(){return row;}
int getColumn(){return column;}
void display();
Matrix& operator=(const Matrix& ma);
Matrix operator+(const Matrix& ma)const;
Matrix operator-(const Matrix& ma)const;
Matrix operator*(const Matrix& ma)const;
private:
int row;
int column;
double** m;
};
Matrix::Matrix(const Matrix &ma){
this->row=ma.row;
this->column=ma.column;
m=new double *[row];
for(int i=0;i