title: C++ template template parameter
body: <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  template &lt;typename T = int&gt;
  struct Foo {
      T t;
      Foo() { cout &lt;&lt; "Foo" &lt;&lt; endl; }
  };
  
  template &lt;typename T&gt;
  struct Baz {
      T t;
      Baz() { cout &lt;&lt; "Baz" &lt;&lt; endl; }
  };
  
  template &lt;typename T&gt;
  struct Bar {
      T t;
      Bar() { cout &lt;&lt; "Bar" &lt;&lt; endl; }
  };
  
  template &lt;template &lt;typename X&gt; class T&gt;
  struct Bar {
      T data;
      Bar() : data() { cout &lt;&lt; "Bar" &lt;&lt; endl; }
  };
  
  int main()
  {
      Bar&lt;Foo&lt;&gt;&gt; a;
  
      Bar&lt;Baz&lt;float&gt;&gt; b;
  
      Bar&lt;int&gt; c;
  
      return 0;
  }
  </code></pre>
  
  <p>I'm just beginning to learn about templates. And I am really confused with template template parameters. I understand that you are passing a template as an argument. In my template class for Bar where it receives a template template argument, what does <code>&lt;typename X&gt;</code> represent? Is <code>typename X</code> a template parameter for <code>class T</code>?</p>
  
  <pre><code>template &lt;template &lt;typename X&gt; class T&gt;
  struct Bar {
      T data;
      Bar() : data() { cout &lt;&lt; "Bar" &lt;&lt; endl; }
  };
  </code></pre>
  
  <p>Also, when I call my template template argument in the main function, I get errors that there are no default constructors for Bar. Why is that?</p>