Question: 1 . Write a class List for a doubly - linked list of characters, using a circular linked list with a dummy node ( List

1. Write a class List for a doubly-linked list of characters, using a circular linked list
with a dummy node (List.h, 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 const_iterator.
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 one-past-theend
of the list. Note that if the list is empty, then begin()== end().
void insert(iterator 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 erase(iterator 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 pre-increment operator (++) which moves to the next element. You can
assume that the iterator is not one-past-the-end of the list.
The pre-decrement 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 4 Question 1 to use the List class instead
of the STL list class. Put this in prob1.cc.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!