I can suggest you that to carefully go through the following code of lines that can demonstrates you how to use the insert() function in the C++ programming as follows :
Code:
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> mvctr (3,100);
vector<int>::iterator a;
a = mvctr.begin();
a = mvctr.insert ( a , 200 );
mvctr.insert (a,2,300);
a = mvctr.begin();
vector<int> anthrvctr (2,400);
mvctr.insert (a+2,anthrvctr.begin(),anthrvctr.end());
int mry [] = { 501,502,503 };
mvctr.insert (mvctr.begin(), mry, mry+3);
cout << "mvctr contains:";
for (a=mvctr.begin(); a<mvctr.end(); a++)
cout << " " << *a;
cout << endl;
return 0;
}
Output:
Code:
mvctr contains: 501 502 503 300 300 400 400 200 100 100 100
Bookmarks