## Advanced Topic 26.1 (cont.)

- Very common in Java and Smalltalk, e.g.
- C++ uses templates, not inheritance
- Avoids cost of virtual functions
- Similar functionality:

  >     template<typename T>
  >     void print_all(const T& items)
  >     {
  >        T::iterator iter = items.begin();
  >        while (iter != items.end())
  >        {
  >           cout << *iter << "\n";
  >           iter++;
  >        }
  >     }

prev |top |next