PPT Slide
The template argument allows to use the adaptor with both apples and oranges, but always yields a new value that is a subclass of Fruit: Fruit * fruitOne = new FruitAdaptor<Apple> (anApple); Fruit * fruitTwo = new FruitAdaptor<Orange> (anOrange);
Since we have a common representation for apples and oranges, it is easy to create containers that will hold fruit values: list<Fruit *> fruitList; // make a list of fruits fruitList.insert(fruitOne); // add an apple fruitList.insert(fruitTwo); // add an orange