Freeing the memory using delete operator for a class object created using new operator gives exception
-
Freeing the memory using delete operator for a class object created using new operator gives exception. The class is class CSnp : public CObject { public: CSnp(); ~CSnp(); char liststr[50]; char sSnpDesc[50]; CTime tDateTime; int iDCSSerialKey; }; Is there anything wrong in the class?
-
Freeing the memory using delete operator for a class object created using new operator gives exception. The class is class CSnp : public CObject { public: CSnp(); ~CSnp(); char liststr[50]; char sSnpDesc[50]; CTime tDateTime; int iDCSSerialKey; }; Is there anything wrong in the class?
class looks fine. make sure you haven't written past the ends of either of those arrays, though.
-
Freeing the memory using delete operator for a class object created using new operator gives exception. The class is class CSnp : public CObject { public: CSnp(); ~CSnp(); char liststr[50]; char sSnpDesc[50]; CTime tDateTime; int iDCSSerialKey; }; Is there anything wrong in the class?
I don't know, you didn't provide the class implementation code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Freeing the memory using delete operator for a class object created using new operator gives exception. The class is class CSnp : public CObject { public: CSnp(); ~CSnp(); char liststr[50]; char sSnpDesc[50]; CTime tDateTime; int iDCSSerialKey; }; Is there anything wrong in the class?
This might happen if you continue to use the pointer after using delete. After delete, set the pointer to 0, to make it easier to catch this.
Best wishes, Hans
-
Freeing the memory using delete operator for a class object created using new operator gives exception. The class is class CSnp : public CObject { public: CSnp(); ~CSnp(); char liststr[50]; char sSnpDesc[50]; CTime tDateTime; int iDCSSerialKey; }; Is there anything wrong in the class?
Any reason you are using char arrays instead of something like CString?
-
Any reason you are using char arrays instead of something like CString?
Because that is a right (warranted by the constitution) of the native developer?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Because that is a right (warranted by the constitution) of the native developer?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]God forbid I infringe upon anyone's rights ;P However,
char sSnpDesc[50];
sounds like some sort of description, and I've seen descriptions longer than 50 chars. -
God forbid I infringe upon anyone's rights ;P However,
char sSnpDesc[50];
sounds like some sort of description, and I've seen descriptions longer than 50 chars.It looks just "A snapshot in the family album". I don't know if Daddy had more than 50 characters. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
It looks just "A snapshot in the family album". I don't know if Daddy had more than 50 characters. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]In World of Warcraft the maximum number of characters you can create over all servers is 50, so this definition looks perfectly valid to me! ;P
-
In World of Warcraft the maximum number of characters you can create over all servers is 50, so this definition looks perfectly valid to me! ;P
-
Freeing the memory using delete operator for a class object created using new operator gives exception. The class is class CSnp : public CObject { public: CSnp(); ~CSnp(); char liststr[50]; char sSnpDesc[50]; CTime tDateTime; int iDCSSerialKey; }; Is there anything wrong in the class?
If you specify the exception, it may provide more information for us to give you feedback. Make sure of a few things: -You're not using the pointer after delete -You're not calling delete on something that has already been deallocated -You're not calling delete on someone else's private member -You're not deallocating across DLL boundries