1 void eraseMap()
 2 {
 3 int n = sizeof(MmMethod);
 4 std::map<CString, int>mapDemo;
 5 for(int i = 0; i < 5; i++)
 6 {
 7 CString strKey;
 8 strKey.Format(_T("key:%d"), i);
 9 mapDemo.insert(std::make_pair(strKey, i));
10 }
11 
12 for(auto it = mapDemo.begin(); it != mapDemo.end(); /*it++*/)
13 {
14 int n = it->second;
15 if(it->second == 2)
16 {
17 mapDemo.erase(it++);//或者it = mapDemo.erase(it);
18 }
19 else
20 {
21 it++;
22 }
23 }
24 }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
猜你喜欢
  • 2021-06-23
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
相关资源
相似解决方案