Recommended Posts

I have a class CD3DStatic, as the constructor parameter it takes a LPCTSTR, allocates new array of TCHAR''s (m_szText = new TCHAR[_dwStrLength], the m_szText is LPTSTR) and copies the string. In the destructor I free it by calling the delete[] m_szText;. When run the MSVC 6.0 shows a dialog Debug Error - Damage after normal block(#55) at 0x... I tried also just delete, but as I expected it didn''t help. Also the strange thing is that the MSVC doesn''t detect any memory leaks if I don''t delete it in the destructor.

Share this post

Link to post

Share on other sites

As was mentioned in a recent thread whenever you design a class with a non-trivial destructor that does something like a delete[] you need to provide a copy constructor and an assignment constructor for the class. Have you got these?