I defined a clsMatrix and used it in my user application, the code snippet as follows:
[code]class clsMatrix {
protected:
double *pM;
int m;
int n;
BOOL m_bAutoDelete;
//m_bAutoDeletenewbAutoDeleteTRUEbAutoDeleteFALSE
public:
clsMatrix();
clsMatrix(int m, int n, double *p = NULL, BOOL bAssign = FALSE);
~clsMatrix();
void Reset();
void Reset(int i, int j, double *p = NULL, BOOL bAssign = FALSE);
// Attributes
int GetM() { return m; }
int GetN() { return n; }
double *GetP() { return pM; }
BOOL EqualSize(clsMatrix &M) { return ((m == M.m) && (n == M.n)); }
public:
// Operators
double * operator [] (int i) { return pM+i*n; }
clsMatrix & operator = (clsMatrix &M);
clsMatrix & operator = (double *p);
clsMatrix & operator = (double x);
clsMatrix & operator += (clsMatrix &M);
clsMatrix & operator += (double *p);
clsMatrix & operator -= (clsMatrix &M);
clsMatrix & operator -= (double *p);
clsMatrix & operator *= (clsMatrix &mtrx); //
clsMatrix & operator *= (double *p);
clsMatrix & operator *= (double a);
clsMatrix & operator /= (double a);
static void X(clsMatrix &mtrx1, clsMatrix &mtrx2, clsMatrix &mtrx); //multiple
static void X(clsMatrix &mtrx1, clsVector &vctr2, clsVector &vctr);
static void X(clsVector &vctr1, clsMatrix &mtrx2, clsVector &vctr);
static void T(clsMatrix &mtrx1, clsMatrix &mtrx); //transpose
static void R(clsMatrix &mtrx1, clsMatrix &mtrx); //inverse
static void S(clsMatrix &mtrx1, int m0, int m1, int n0, int n1, clsMatrix &mtrx, int m = 0, int n = 0);
static void S(clsVector &vctr1, int m0, int m1, clsVector &vctr, int m = 0);
double e();
double e2();
double ei();
public:
BOOL LoadT(char *pszFile);
BOOL SaveT(char *pszFile);
friend class clsVector;
};
clsMatrix::clsMatrix()
{
m = n = 0;
pM = NULL;
m_bAutoDelete = FALSE;
}
the problem happens in the clsMatrix constructor, whenever a clsMatrix object is declared, the SIGBUS error occurs, unless the contructor is empty.
Eric[/code]