Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . Write a class List for a doubly - linked list of characters, using a circular linked list with a dummy node ( List
Write a class List for a doublylinked list of characters, using a circular linked list
with a dummy node Listh List.cc The nodes Element should be declared as
a private nested class. Also declare iterator as a public nested class. For simplicity,
you do not need to implement constiterator.
You should implement the following member functions:
Default constructor: initializes the list to an empty list.
Destructor: deletes all nodes in the list.
begin end: return iterators that point to the beginning and onepasttheend
of the list. Note that if the list is empty, then begin end
void insertiterator it char c: inserts the character c into the position
specified by the iterator it If it end the character is appended to the
list.
void eraseiterator it: erases the character at the position specified by the
iterator it If it end this function does nothing.
Make sure that List is a friend of iterator. For the iterator nested class, implement
the following member functions:
A default constructor which initializes the pointer to nullptr.
A private constructor which takes a pointer to Element and initializes itself to the
pointer. Making the constructor private means that only List member functions
can initialize an iterator directly.
The preincrement operator which moves to the next element. You can
assume that the iterator is not onepasttheend of the list.
The predecrement operator which moves to the previous element. You can
assume that the iterator is not at the beginning of the list.
The dereference operator Provide two versions of the dereference operator:
one returning a reference to the character data, and another returning a constant
reference.
The comparison operators and which compare the pointers.
Modify the posted solution of Assignment Question to use the List class instead
of the STL list class. Put this in probcc
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started