#include
<
iostream
>
#include < vector >
using namespace std;
int main()
... {
vector<int> vec(10,12);
for(vector<int>::iterator iter=vec.begin();iter!=vec.end();++iter)
cout<<*iter<<" ";
cout<<endl;
// The following segment has problem.
// The while loop will not end.
vector<int>::iterator first=vec.begin();
while(first!=vec.end())
...{
first=vec.insert(first,42);
++first;
}
for(vector<int>::iterator iter=vec.begin();iter!=vec.end();++iter)
cout<<*iter<<" ";
cout<<endl;
return 0;
}
#include < vector >
using namespace std;
int main()
... {
vector<int> vec(10,12);
for(vector<int>::iterator iter=vec.begin();iter!=vec.end();++iter)
cout<<*iter<<" ";
cout<<endl;
// The following segment has problem.
// The while loop will not end.
vector<int>::iterator first=vec.begin();
while(first!=vec.end())
...{
first=vec.insert(first,42);
++first;
}
for(vector<int>::iterator iter=vec.begin();iter!=vec.end();++iter)
cout<<*iter<<" ";
cout<<endl;
return 0;
}