insert
Syntax:
#include <deque> iterator insert( iterator loc, const TYPE& val ); void insert( iterator loc, size_type num, const TYPE& val ); template<TYPE> void insert( iterator loc, input_iterator start, input_iterator end ); The insert() function either:
For example: // Create a vector, load it with the first 10 characters of the alphabet vector<char> alphaVector; for( int i=0; i < 10; i++ ) { alphaVector.push_back( i + 65 ); } // Insert four C's into the vector vector<char>::iterator theIterator = alphaVector.begin(); alphaVector.insert( theIterator, 4, 'C' ); // Display the vector for( theIterator = alphaVector.begin(); theIterator != alphaVector.end(); theIterator++ ) { cout << *theIterator; } This code would display: CCCCABCDEFGHIJ |