一、CMatrix类代码
----- 1. 成员变量
private:
int m_nRow ;
int m_nCol ;
double * m_pData ;
----- 2. 头文件
#ifndef CMATRIX_H
#define CMATRIX_H
#include<iostream>
#include<assert.h>
using namespace std;
class CMatrix
{
public:
CMatrix();
CMatrix(int nRow, int nCol, double* pData);
CMatrix(const char *strPath);
CMatrix(const CMatrix &m);
bool create(int nRow, int nCol, double* pData=NULL);
void Release();
~CMatrix();
CMatrix& operator +(const CMatrix& m);
CMatrix& operator =(const CMatrix& m);
CMatrix& operator +=(const CMatrix& m);
bool operator ==(const CMatrix& m);
double& operator[](int m)
{
assert(m_nCol*m_nRow > m);
return m_pData[m];
}
double& operator()(int m, int n)
{
assert(m_nCol*m_nRow > m*n+n);
return m_pData[m*n+n];
}
friend istream&