listsstacksand queues struct node object datanode *prevnode *nextnodeconst object object}node nullptrnode nullptr datad }prevp }nextn nodeobject &dnode nullptrnode nullptr datastd::moved }prevp }nextn }figure nested node class for list class howeverin our casewe can avoid much of the syntactical baggage because we are not adding new datanor are we intending to change the behavior of an existing method we arehoweveradding some new methods in the iterator class (with very similar signatures to the existing methods in the const_iterator classas resultwe can avoid using virtual even sothere are quite few syntax tricks in const_iterator at lines and const_iterator stores as its single data member pointer to the "currentnode normallythis would be privatebut if it were privatethen iterator would not have access to it marking members of const_iterator as protected allows the classes that inherit from const_iterator to have access to these membersbut does not allow other classes to have access at lines and we see the constructor for const_iterator that was used in the list class implementation of begin and end we don' want all classes to see this constructor (iterators are not supposed to be visibly constructed from pointer variables)so it can' be publicbut we also want the iterator class to be able to see itso logically this constructor is made protected howeverthis doesn' give list access to the constructor the solution is the friend declaration at line which grants the list class access to const_iterator' nonpublic members the public methods in const_iterator all use operator overloading operator==operator!=and operatorare straightforward at lines to we see the implementation of operator+recall that the prefix and postfix versions of operator+are completely different in semantics (and precedence)so we need to write separate routines for each form they have the same nameso they must have different signatures to be distinguished +requires that we give them different signatures by specifying an empty parameter list for the prefix form and single (anonymousint parameter for the postfix form then ++itr calls the zero-parameter operator++and itr+calls the one-parameter operator+the int parameter is never usedit is present only to give different signature the implementation suggests thatin many cases where there is choice between using the prefix or postfix operator++the prefix form will be faster than the postfix form in the iterator classthe protected constructor at line uses an initialization list to initialize the inherited current node we do not have to reimplement operator=