Question: Figure 4.2 shows the array-based list implementation, named AList. AList inherits from abstract class List and so must implement all of the member functions of
Figure 4.2 shows the array-based list implementation, named AList. AList inherits from abstract class List and so must implement all of the member functions of List (Figure 4.1).
Use the AList class (Array-Based List) on Figure 4.2 and test each individual member function. Present a menu driven interface to the user. Use your own data for testing and the given data.
given data:
AL1 : 40, 60, 80, 10, 120, 1000 ; AL2 : 1, 3.50, 5, 5.8, 6, 6.5;


template class List // List ADT private void operator = (const List&) List (const List&) // Protect assignment // Protect copy constructor {} public / Default constructor List) virtual List) // Base destructor // Clear contents from the list, to make it empty virtual void clear 0; / Insert an element at the current location // item: The element to be inserted virtual void insert (const E& item)0; // Append an element at the end of the list // item: The element to be appended virtual void append(const E& item) = 0; / Remove and return the current element / Return: the element that was removed virtual E remove() 0; // Set the current position to the start of the list virtual void moveToStart )0 /l Set the current position to the end of the list virtual void moveToEnd) 0; // Move the current position one step left. No change // if already at beginning virtual void prev() 0; // Move the current position one step right. No change // if already at end virtual void next ) 0; // Return: The number of elements in the list virtual int length ) const 0; // Return: The position of the current element. virtual int currPos ) const0 // Set current position // pos The position to make current virtual void moveToPos (int pos)0 / Return: The current element. virtual const E& getValue ) const0; Figure 4.1 The ADT for a list. template class List // List ADT private void operator = (const List&) List (const List&) // Protect assignment // Protect copy constructor {} public / Default constructor List) virtual List) // Base destructor // Clear contents from the list, to make it empty virtual void clear 0; / Insert an element at the current location // item: The element to be inserted virtual void insert (const E& item)0; // Append an element at the end of the list // item: The element to be appended virtual void append(const E& item) = 0; / Remove and return the current element / Return: the element that was removed virtual E remove() 0; // Set the current position to the start of the list virtual void moveToStart )0 /l Set the current position to the end of the list virtual void moveToEnd) 0; // Move the current position one step left. No change // if already at beginning virtual void prev() 0; // Move the current position one step right. No change // if already at end virtual void next ) 0; // Return: The number of elements in the list virtual int length ) const 0; // Return: The position of the current element. virtual int currPos ) const0 // Set current position // pos The position to make current virtual void moveToPos (int pos)0 / Return: The current element. virtual const E& getValue ) const0; Figure 4.1 The ADT for a list