iterator endreturn &objectssize]const_iterator endconst return &objectssize]static const int spare_capacity privateint thesizeint thecapacityobject objects}figure (continuedfinallyat lines to we see the declaration of the iterator and const_iterator nested types and the two begin and two end methods this code makes use of the fact that in ++ pointer variable has all the same operators that we expect for an iterator pointer variables can be copied and comparedthe operator yields the object being pointed atandmost peculiarlywhen +is applied to pointer variablethe pointer variable then points at the object that would be stored next sequentiallyif the pointer is pointing inside an arrayincrementing the pointer positions it at the next array element these semantics for pointers date back to the early with the programming languageupon which +is based the stl iterator mechanism was designed in part to mimic pointer operations consequentlyat lines and we see typedef statements that state the iterator and const_iterator are simply other names for pointer variableand begin and end need to simply return the memory addresses representing the first array position and the first invalid array positionrespectively the correspondence between iterators and pointers for the vector type means that using vector instead of the +array is likely to carry little overhead the disadvantage is thatas writtenthe code has no error checks if the iterator itr goes crashing past the end markerneither ++itr nor *itr will necessarily signal an error to fix this problem would require that the iterator and const_iterator be actual nested class types rather than simply pointer variables using nested class types is much more common and is what we will see in the list class in section implementation of list in this sectionwe provide the implementation of usable list class template as in the case of the vector classour list class will be named list to avoid ambiguities with the library class recall that the list class will be implemented as doubly linked list and that we will need to maintain pointers to both ends of the list doing so allows us to maintain constant time cost per operationso long as the operation occurs at known position the known position can be at either end or at position specified by an iterator