Templates of templates

The first thing which really took me days to figure out was writing a class template which accepted further templates as arguments. Finally I was taught how to do it and came up with the following code segment:

template <class T, template <class> class Container = CTree>
  class CSet: public Container<T> {
      CSet operator +(const CSet &);
      CSet operator -(const CSet &);
      CSet operator /(const CSet &);
      CSet operator ^(const CSet &);

This creates a template of the class CSet, which accepts two parameters: The class of the objects to save into the set, and a template of a class (which in this example should implement some kind of container) which accepts one parameter, again the type of the objects to store. This way it is possible to create whatever nested templates one desires.

Vectors of vectors of vectors ...

class X: public std::vector<X> { };