Due date Wednesday April 10
The purpose of this assignment is to develop some familiarity with
generic programming, i.e. templates, as well as containers and iterators.
The previous assignments have dealt ad nauseam with lists and list
traversals. How much easier is it to do this kind of programing using
template classes? To find out, do the following:
a) Write a template class for a doubly-linked list, parametrized by the
class that is stored at every list node. Member functions should include
insertion and search. Assume that the class parameter has a "<" operator
that can be used to establish a sorting order for the list.
b) Write an iterator class over this list.
c) Rewrite the calculator using this class. In particular, use the
iterator in the addition and multiplication member functions.
d) As an experiment, suppose we want to manipulate univariate polynomials.
How much code would you have to rewrite? Could you make the polynomial
class itself into a template, parameterized by the number of variables
in a term? Feel free to explore here.
e) Comment on where all of this buys you anything.