INTRODUCTION This project consists of two parts, the second of which appears below. The first part is to write a
class that implements an
unordered list abstract data type using a
doubly-linked list with pointers to both its first and last nodes. The second part of the project specifies how a program will use the class.
DESCRIPTION Write a class that implements an
unordered list ADT. This class should provide the following operations:
- A default constructor that initializes a newly declared list to be empty.
- A destructor that deletes all the nodes in a list.
- append(entry), which appends the item entry at the end of the list.
- remove_last(), which removes the last item from the list.
- An output function that prints the list in forward order to an output stream; you may assume that "<<" can be used with items of the list.
Implement the ordered-list ADT using a
doubly-linked list with pointers to both its first and last nodes, as in this figure:

In the class that implements the list as a doubly linked list, include
two data members: a pointer to the first node in the list, and a pointer to the last node in the list. Note that the pointer to the list's last node makes both
append() and
remove_last() fast. Thus the class's data members will be something like this:
struct Node
{
Item data;
Node *next;
Node *back;
};
Node *first;
Node *last;
You may want to write a program with which you can test this class. Here's something to do with the unordered-list implementation that you have (presumably) just completed: DESCRIPTION Consider this simple line-editing problem: A program reads characters one at a time, then prints them back to the terminal in order. However, the character `#' is not to be saved. Rather, it indicates that the program is to delete the most recent character. After reading reaches the end of the line, the surviving characters are printed in forward order. For example:
input: abcd##ef =>
output: abef
Write a program that uses the unordered-list implementation to solve the editing problem just described. A doubly-linked list, provided by the class, will hold the characters of the input line in the order in which they are entered.
INPUT The program reads a line of characters, some of which may be the delete character `#'.
OUTPUT The program prints the surviving (non-deleted) characters from the input, in the order in which they appeared.
ERRORS The program may assume that the input is as described; it need not detect any errors.
EXAMPLE A run of the program might look like this: Enter a line of characters; # => delete the last character.
-> aabbcc#ddee##fg#h
aabbcddfh
and another might look like this: Enter a line of characters; # => delete the last character.
-> djfg#######abc#def
abdef
HINTS In the client program, the Item type in the unordered list class is
char. For the client program, recall that the function get() reads the next character from the named input stream into the function's parameter, which is passed by reference.
Example: cin.get(ch);