C++矩阵运算的实现
C++控制台程序,利用指针进行矩阵的加、减、乘运算 头文件代码如下: #ifndef MATRIX_H #define MATRIX_H #include <iostream> using namespace std; class Matrix { public: Matrix(int zRow = 0, int zLine = 0, double **zPM = NULL);//构造函数 Matrix(Matrix &zMatrix);//拷贝构造函数 friend ostream& operator << (ostream& output, const Matrix& zMatrix);//重载 << friend istream& operator >> (istream& input, Matrix& zMatrix);//重载 >> Matrix operator + (const Matrix& zMatrix)const;//重载 + Matrix operator - (const Matrix& zMatrix)const;//重载 - Matrix operator * (const Matrix& zMatrix)const;//重载 * Matrix& operator =(const Matrix& zMatrix);//重载 = double& operator () (int zRow, int zLine);//提取、设置矩阵的元素的值 int GetRow();//获取行数 int GetLine();//获取列数 ~Matrix();//析构函数 private: int row, line;//矩阵的行和列 double **pMatrix;//动态分配矩阵 }; #endif
- 1
- 粉丝: 0
- 资源: 3
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助