解VC++的来啊

来源:百度知道 编辑:UC知道 时间:2024/06/04 07:49:42
设计一个矩阵类,数据成员有矩阵的行数和列数,在这个矩阵类中要实现以下功能:
1. 对=,+,-,+=,-=运算符进行重载。
2. 对方阵能够转置。
3. 能够对矩阵清空。

//
// matrix.h
//
// CMatrix - 矩阵 : 于2005-09-28 最后一次修改于2005-10-11 曾潜明
//

#ifndef __MATRIX_DOT_H__
#define __MATRIX_DOT_H__

template <class T>
void Swap(T& a, T& b)
{
T temp;

temp = a;
a = b;
b = temp;
}

class CMatrix
{
static double ZERO;//极小值
public:
CMatrix(int row = 3, int col = 3); //
CMatrix(const CMatrix& right); //拷贝构造函数
~CMatrix();
void Show(const char* pre = NULL)const; //输出矩阵
void Free();
int Resize(int row, int col); //重新定义矩阵大小
int GetRow()const{ return m_iRow; } //返回矩阵行数
int GetCol()const{ return m_iCol; } //返回矩阵列数
int RowSwap(int x, int y); //行交换,成功返回1,否则0
int ColSwap(int x, int y); //列交换
static void SetZero(double z); //设定ZERO的值,所有CMatrix实例精度都将改变

const CMatrix Transpose()const; //返回转置矩阵
const CMatrix Adjoint()const; //伴随矩阵
const CMat