insert

Syntax:

    #include <set>
    iterator insert( iterator pos, const TYPE& val );
    iterator insert( const TYPE& val );
    void insert( input_iterator start, input_iterator end );

The function insert() either:

For example, the following code uses insert() to add elements to a multiset:

    multiset<int> ms;
    multiset<int>::iterator iter;
    int i;
 
    for (i = 1; i < 5; i++) {
        ms.insert(i);
        ms.insert(i*i);
        ms.insert(i-1);
    }
 
    cout << "ms is:" ;
    for (iter = ms.begin(); iter != ms.end(); iter++)
        cout << " " << *iter;
    cout << "." << endl;

The above code produces the following output:

ms is: 0 1 1 1 2 2 3 3 4 4 9 16.