Predefined Iterator typedefs

Figure 15.8 shows the predefined iterator typedefs that are found in the Standard Library container class definitions. Not every typedef is defined for every container. We use const versions of the iterators for traversing const containers or non-const containers that should not be modified. We use reverse iterators to traverse containers in the reverse direction.

Image

Fig. 15.8. Iterator typedefs.


Image Error-Prevention Tip 15.3

Operations performed on a const_iterator return references to const to prevent modification to elements of the container being manipulated. Using const_iterators where appropriate is another example of the principle of least privilege.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.48.218