December 7th, 2003, 10:31 AM
In my MFC application in which I have a CArray Object defined like this;
CArray<CCard, CCard&> m_CardArray; //this array contains the cards owned by a particular player
The CCard objects are dynamically created in the heap throughout the program and added to the m_CardArray;
CCard *pCard = new CCard;
Here pCard is a local pointer
My problem is how to delete the CCard objects created on the heap like this so that no memory leak would be detected.
delete the the CCard objects created on the heap?
Please Help me.
December 7th, 2003, 03:21 PM
You should be able to delete it right after the Add().
You are storing CCard objects into the CArray, not
In this case, I would just use a CCard veriable in the
first place ...
December 7th, 2003, 05:36 PM
Thanx a lot philip for opening my eyes. Now I realize how dumb I have been.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.