CTypedPtrList
-
Hello, I have this variable in the Doc class. CTypedPtrList m_objectsList; Suppose at present it has 5 entries. I want to delete 3rd record. then how to achieve it? I tried. POSITION pos = m_objectsList.GetHeadPosition(); UINT cnt=0; while(pos!=NULL) { CObjData *objFmList = m_objectsList.GetNext(pos); cnt++; if(cnt==3) delete objFmList; } but then if next time I go to read this m_objectsList, program gives memory related error. How to do it safe way? thanks Leya
-
Hello, I have this variable in the Doc class. CTypedPtrList m_objectsList; Suppose at present it has 5 entries. I want to delete 3rd record. then how to achieve it? I tried. POSITION pos = m_objectsList.GetHeadPosition(); UINT cnt=0; while(pos!=NULL) { CObjData *objFmList = m_objectsList.GetNext(pos); cnt++; if(cnt==3) delete objFmList; } but then if next time I go to read this m_objectsList, program gives memory related error. How to do it safe way? thanks Leya
-
You forgot to remove the item from the list. So at the next time you are deleting the object, which is previously deleted. - NS -