map erase clear

#include <stdio.h>
#include
<map>
#include
<string.h>
#include
<algorithm>
#include
<iostream>

using namespace std;

int main( )
{
map
<int,string>mp;
mp[
1] = "abc";
mp[
2] = "bcd";
mp[
3] = "efg";
map
<int,string>::iterator iter;
iter
= mp.find(1);
// 数据的清空与删除
//mp.erase(mp.begin( ),mp.end( ));
mp.erase(iter);
///mp.clear( );
for (iter = mp.begin( ); iter != mp.end( ); iter++)
cout
<<iter->first<<" "<<iter->second<<endl;
return 0;
}

posted on 2011-07-28 23:06  more think, more gains  阅读(340)  评论(0)    收藏  举报

导航