Advanced Placement Computer Science AB:
Quiz 12:  Templates and Lists
   Sewickley Academy, 2000-2001

Write a templated List class with the following public methods:

itemType* getFirst();
void setFirst(itemType* pFirst);
List<itemType>* getRest();
void setRest(List<itemType>* pRest);
Hint:  be sure to delete m_pFirst and m_pRest in your destructor, but nowhere else.

Write a main() which demonstrates this by creating either an apstring or an int version of List, and then exhibiting the following behavior:

List of [s]trings or [i]ntegers: s
Command (push, pop, or quit): push foo
List = ( foo )
Command (push, pop, or quit): push bar
List = ( bar foo )
Command (push, pop, or quit): pop
Popped:  bar
List = ( foo )
Command (push, pop, or quit): push blat
List = ( blat foo )
Command (push, pop, or quit): pop
Popped:  blat
List = ( foo )
Command (push, pop, or quit): pop
Popped:  foo
List = ( )
Command (push, pop, or quit): quit
Good bye.
Good luck!


See Course Home Page.