#include <iostream>
#include <deque>
#include <vector>
using namespace std;
int main ()
{
deque<int> mydeque;
deque<int>::iterator it;
// set some initial values:
for (int i=1; i<6; i++) mydeque.push_back(i); // 1 2 3 4 5
it = mydeque.begin();
++it;
it = mydeque.insert (it,30); // 1 10 2 3 4 5
// "it" now points to the newly inserted 10
mydeque.insert (it,2,22); // 1 20 20 10 2 3 4 5
// "it" no longer valid!
it = mydeque.begin()+2;
vector<int> myvector (2,35);
mydeque.insert (it,myvector.begin(),myvector.end());
// 1 20 30 30 20 10 2 3 4 5
cout << "mydeque contains:";
for (it=mydeque.begin(); it<mydeque.end(); ++it)
cout << " " << *it;
cout << endl;
return 0;
}
This post has been edited by jimblumberg: 13 October 2012 - 06:03 AM
Reason for edit:: Added missing Code Tags, Please learn to use them.

New Topic/Question
Reply



MultiQuote



|