STL中map的方法erase()问题
对erase方法不是特别了解的先看一下这个资料http://hi.baidu.com/sdkinger/item/dcad78e374707ff12b09a453
#include "stdafx.h"STL,迭代器,map?erase
#include <map>
#include <iostream>
using namespace std;
typedef map<int,int> rqInfo;
int main()
{
rqInfo Map;
Map.insert(rqInfo::value_type(1,10));
Map.insert(rqInfo::value_type(2,20));
Map.insert(rqInfo::value_type(3,30));
rqInfo rqinfomap;
rqinfomap = Map;
rqInfo::iterator Iterator= Map.begin();
rqInfo::iterator Iteratortemp=Iterator;
printf("index=%d\n",Iterator->second);
printf("index=%d\n",Iteratortemp->second);
Map.erase(Iterator);
Iteratortemp++;//此处为什么Iterator失效后,Iteratortemp也跟着失效了呢,莫非是删除此元素的位置之后,所有引用此处的迭代器都会失效,懂的可以讲解一下。
printf("index=%d\n",Iteratortemp->second);
}