STL list刪除元素出錯

  1. std::list<CRDepartment>::iterator it = deptList.begin();
  2. for (; it != deptList.end();)
  3. {
  4. CString strName = it->szName;
  5. OutputDebugString("\n********************關係列表*************************\n");
  6. OutputDebugString(strName);

  7. if (strName == _T("陌生人"))
  8. {
  9. it = deptList.erase(it);
  10. }
  11. else if (strName == _T("黑名單"))
  12. {
  13. it = deptList.erase(it);
  14. }
  15. else
  16. {
  17. it++;
  18. }
  19. }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章