List Splice
#include <list>
#include <string>
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
list<string> dictionary, bWords;
dictionary.push_back("A");
dictionary.push_back("B");
dictionary.push_back("C");
dictionary.push_back("D");
dictionary.push_back("E");
dictionary.push_back("F");
bWords.push_back("G");
bWords.push_back("H");
bWords.push_back("I");
list<string>::iterator it;
int i;
for (it = dictionary.begin(), i = 0; i < 3; ++it, ++i);
dictionary.splice(it, bWords);
for (it = dictionary.begin(); it != dictionary.end(); ++it) {
cout << *it << endl;
}
return (0);
}
Related examples in the same category