PPT Slide
We have all the elements necessary to maintain both apples and oranges in the same collection, and to perform polymorphic operations on these values: Apple anApple("Rome"); Orange anOrange; list<Fruit *> fruitList; // declare list of pointers to fruits fruitList.insert(newFruit(anApple)); fruitList.insert(newFruit(anOrange)); list<Fruit *>::iterator start = fruitList.begin(); list<Fruit *>::iterator stop = fruitList.end(); // loop over and print out all fruits in container for ( ; start != stop; ++start) { Fruit & aFruit = *start; // get current fruit aFruit.print(cout); }