Introduction to OOP: Chapter 14 : Polymorphism [next] [previous] [audio] [real] [text]

Generics and Templates

Yet another form of polymorphism is the use of generics or templates. Here a type can be used as a parameter is a class description.

template <class T> class link {
	T value;
	link<T> * nextLink;

The declaration provides the actual type:

	link<int> intLink; // link with integer value
Intro OOP, Chapter 14, Slide 21