1. CMatrix(): 不带参数的构造函数
CMatrix::CMatrix() //方法1 { m_nRow = 0; m_nCol = 0; *m_pData = NULL; } CMatrix::CMatrix():m_nRow(0),m_nCol(0),m_pData(NULL) //方法2 { }
2. 带行、列及数据指针等参数的构造函数,并且参数带默认值
CMatrix::CMatrix(int nRow, int nCol, double *pData) : m_pData(0) { Create(nRow, nCol, pData); }
3. 带文件路径参数的构造函数
CMatrix::CMatrix(const char * strPath) { m_pData = 0; m_nRow = m_nCol = 0; ifstream cin(strPath); cin >> *this; }
4. 拷贝构造函数
CMatrix::CMatrix(const CMatrix& m):CMatrix(m.m_nRow, m.m_nCol, m.m_pData) { m.m_pData = NULL; *this = m; }