为啥这个输出这么怪,vector里插入了元素,原有的迭代器就用不了了吗?
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int myint[10] = {1,2,3,4,5,6,7,8,9,0};
vector<int> rhs(myint,myint + sizeof(myint)/myint[0]);
vector<int>::iterator it = rhs.begin();
cout <<" *it "<< *it << endl;
rhs.push_back(1);
cout <<" *it "<< *it << endl;
return 0;
}
输出:
*it 1
*it 0
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…