Generics and Templates

Yet another form of polymorphism is the idea of generics, or templates as they are called in C++. The idea of a template is that a type can be used as a parameter is a class description. The slide, for exmaple, shows a link in a linked list class abstraction. The template parameter must be filled with a type name. For example, we can make a linked list of integers , or alinked list of reals.

Generics provide a very effective mechanism for reuse while preserving strong type checking.

[audio] [real] Text to accompany slide21, in Chapter 14 of An Introduction to Object-Oriented Programming