Hello,
I've a Class with a two dimension array pointer. It works fine, but when I'm trying to exit from the application the emulator returns with an error "unknown software exception...".
I know this caused by the wrong destruction... (when i'm commenting out my iTable variable it works fine...)
How can i destruct a two dimension array pointer?
Why isn't enough "delete iTable;"?
my header file: ctable.h
Code:#ifndef CTABLE_H #define CTABLE_H #include <e32base.h> class CTable { public: static CTable* NewL(TInt aW, TInt aH); static CTable* NewLC(TInt aW, TInt aH); ~CTable(); private: void ConstructL(TInt aW, TInt aH); CTable(); private: TInt8 **iTable; }; #endif // CTABLE_H
my cpp file:
code updated.Code:#include "ctable.h" #include "Cascade.pan" #include <e32math.h> CTable* CTable::NewL(TInt aW, TInt aH){ CTable* self = NewLC(aW,aH); CleanupStack::Pop(); return self; } CTable* CTable::NewLC(TInt aW, TInt aH){ CTable* self = new (ELeave)CTable(); CleanupStack::PushL(self); self->ConstructL(aW,aH); return self; } void CTable::ConstructL(TInt aW, TInt aH) { iTable = (TInt8**) new (ELeave)(TInt8[aW]); int i; for(i=0;i<aW+1;i++){ iTable[i]=new (ELeave)TInt8[aH]; } } CTable::CTable() { //non-Leave construction } CTable::~CTable(){ if(iTable){ delete iTable; iTable = NULL; } }

Reply With Quote


