#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int > vctInt;
vector<int>::iterator iter;
for (int i = 0; i < 10; i++)
{
vctInt.push_back(i);
}
for (iter = vctInt.begin(); iter != vctInt.end(); iter++)
{
cout << *iter << " ";
}
cout << endl;
for (iter = vctInt.begin(); iter != vctInt.end(); )
{
if (*iter == 9)
{
iter = vctInt.erase(iter);
continue;
}
++iter;
}
cout << endl;
for (iter = vctInt.begin(); iter != vctInt.end(); iter++)
{
cout << *iter <<" ";
}
cout << endl;
system("pause");
return 0;
}
运行结果: