Exercise 6, spring 2006 ----------------------- Templates In previous exercise a double linked list and a binary tree for integers were examined. If now only examining the double linked list, what if one would like to have a double linked list that would store, say, doubles - what modifications would have to be done to the code? For example examine the code of DLlist::Remove()-method(see the example code for that exercise) - how would you change it if the list contained doubles instead of ints and how the type of stored data is visible there? Examine also the rest of the code of double linked list and think what parts would remain practically the same and what would work even though the list would store doubles, or some other type. You may notice that the code would be essentially the same. So surely there is a way to use the existing code for the list of doubles? Indeed there is - only 'minor' modifications are needed to make it a template-class, which enables not only the use of doubles, but many other types as well. So, here's the task: modify the double linked list class to template class, and test it with a main program - create lists of different type (int, double, etc.). Some remarks about templates: -The syntax can be quite tricky, but try not to put all the concentration on getting the syntax correct, but instead try to see the idea. Also with template classes, the class methods should be written to the same header file where the class is defined. -There are differences between compilers, meaning for example that a code that compiles fine with some compiler, results to loads of error messages with some other compiler - this may happen especially with templates. So don't be surprised if a code that works with, for example, Dev-c++ doesn't work with visual c++ 6.0(used in exercises), or the other way round, although this might not be a problem with very basic template-syntax.