*itrreturns reference to the object stored at iterator itr' location the reference returned may or may not be modifiable (we discuss these details shortlyr itr ==itr returns true if iterators itr and itr refer to the same location and false otherwise itr !=itr returns true if iterators itr and itr refer to different location and false otherwise with these operatorsthe code to print would be forvector::iterator itr begin)itr ! end)++itr cout <*itr <endlthe use of operator overloading allows one to access the current itemthen advance to the next item using *itr+thusan alternative to the fragment above is vector::iterator itr begin)whileitr != endcout <*itr+<endlcontainer operations that require iterators for the last issuethe three most popular methods that require iterators are those that add or remove from the list (either vector or listat specified positionr iterator insertiterator posconst object )adds into the listprior to the position given by the iterator pos this is constant-time operation for listbut not for vector the return value is an iterator representing the position of the inserted item iterator eraseiterator pos )removes the object at the position given by the iterator this is constant-time operation for listbut not for vector the return value is the position of the element that followed pos prior to the call this operation invalidates poswhich is now stalesince the container item it was viewing has been removed iterator eraseiterator startiterator end )removes all items beginning at position startup tobut not including end observe that the entire list can be erased by the call erasec begin) endexampleusing erase on list as an examplewe provide routine that removes every other item in liststarting with the initial item thus if the list contains then after the method is invoked it will contain we do this by stepping through the list and using the erase method on every second item on listthis will be linear-time routine because each of the calls to erase takes constant timebut in vector the entire routine will take quadratic time because each of the calls to erase is inefficientusing (ntime as resultwe would normally write the code for list only howeverfor experimentation purposeswe write general function template that will work with both list or vectorand then provide