代码实现
CMatrix.h
#ifndef CMATRIX_H
#define CMATRIX_H
//防止被重复引用
#include <iostream>
using namespace std;
class CMatrix
{
public:
//函数的构建
CMatrix();
CMatrix(int nRow, int nCol, double* pData = NULL);
CMatrix(const CMatrix& m);
CMatrix(const char* strPath);
~CMatrix();
//函数的创建删除和设置
bool Create(int nRow, int nCol, double* pData = NULL);
void Set(int nRow, int nCol, double dVale);
void Release();
//友元函数
friend istream& operator>>(istream& is, CMatrix& m);
friend ostream& operator<<(ostream& os, const CMatrix& m);
//操作符的重载
CMatrix& operator =(const CMatrix& m);
CMatrix& operator +=(const CMatrix& m);
double& operator[](int nIndex);
double& operator()(int nRow, int nCol);
bool operator ==(const CMatrix& m);
bool operator !=(const CMatrix& m);
operator double();
private:
int m_nRow;
int m_nCol;
double* m_pData;