Illustrates erase() and insert() member functions if the vector container. The program also uses ostream_iterator, copy() functions of the algorithm header file. ostream_iterator is another adaptor which provides output iterator functionality and will write the data out. The ostream_iterator constructortakes two arguments, the stream to be used and the separator. It prints the separator between elements the syntax is: ostream_iterator<int>out(vout.””); copy() is a function of the algorithm header file which can be used with any of the containers. The other function of the algorithm header file are discussed at the end of the chapter, copy() function helps in copying a sequence. It has three arguments. The first two arguments denote the beginning and the end of the sequence to be copied and the third argument gives the destination. For example the command. Copy(v.begin(),v.end()(,out); display the elements of the vector form the beginning till the end. Find () is another function of the algorithm header file which searches a ranges for a value and returns an iterator to the first occurrence of the elements. |