Combine insert and end to add elements to the end of vector
#include <iostream>
#include <cassert>
#include <algorithm>
#include <string>
#include <list>
#include <deque>
#include <vector>
using namespace std;
int main()
{
vector<string> vec;
vec.insert(vec.end(), "AAA");
vec.insert(vec.end(), "BBBB");
vec.insert(vec.end(), "CCCCC");
vector<string>::iterator pos;
for (pos=vec.begin(); pos!=vec.end(); ++pos) {
cout << *pos << ' ';
}
return 0;
}
/*
AAA BBBB CCCCC
*/
Related examples in the same category