Hi!
I built this class, however when I executed my program the memory run out quickly, because I wasn't making any "deletes", so I added the delete in the destructor, but It crashes there... what's wrong?
class CMatrix
{
public:
void Identity();
void SetMaxColRow(int nRow, int nCol);
void SetElement(int nRow, int nCol, long double element);
void Show();
long double GetElement(int nRow, int nCol);
CMatrix operator+(CMatrix tmpMatriz);
CMatrix operator-(CMatrix tmpMatriz);
CMatrix operator*(long double scalar);
CMatrix operator*(CMatrix tmpMatriz);
CMatrix Transpose();
void CMatrix::Invert();
CMatrix GetInverted() const;
CMatrix(int nRows, int nCols);
CMatrix();
virtual ~CMatrix();
int m_nRows;
int m_nCols;
private:
long double *m_pMatriz;
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
// constructor
CMatrix::CMatrix(int nRows, int nCols)
{
SetMaxColRow(nRows, nCols);
}
// constructor
CMatrix::CMatrix()
{
m_nCols = NULL;
m_nRows = NULL;
m_pMatriz = NULL;
}
// destructor
CMatrix::~CMatrix()
{
if (m_pMatriz != NULL)
delete[] m_pMatriz;
}