title: c++ class member variable of the nested template type
body: <p>I would like to create a templated class (<code>C2</code>), using as a template a class which is also templated (<code>C1</code>). Moreover in <code>C2</code> create a variable of the same type, which was used as template of the class <code>C1</code>.</p>
  <pre><code>template &lt;typename Ttype&gt;
  class C1{
  public:
      Ttype var;
  }
  
  template&lt;class T&gt; //class T always templated
  class C2{
  public:
      T x;
  //  ? y; &lt;&lt; variable of template type of the class T
  }
  
  int main()
  {
      C1&lt;int&gt;  instanceInt;
      C1&lt;long&gt; instanceLong;
      
      C2&lt;C1&lt;int&gt;&gt; foo; //C2.y should be int
  }
  </code></pre>
  <p>My initial implementation of the class <code>C2</code> was as follows, however it results in <code>error: identifier &quot;Ttype&quot; is undefined</code>. <strong>Why doesn't compiler see the Ttype?</strong></p>
  <pre><code>template &lt;template &lt;class Ttype&gt; class Tparam&gt;
  class C2 {
  
  public:
      Tparam&lt;Ttype&gt; x;
      const Ttype y;
  };
  </code></pre>
  <p>So my working, but not so nice solution is using a typedef.</p>
  <pre><code>template &lt;typename Ttype&gt;
  class C1{
  public:
      typedef Ttype Ctype
      Ttype var;
  }
  
  template&lt;class T&gt;
  class C2{
  public:
      typedef typename T::Ctype Ttype;
      T x;
      Ttype y;
  }
  </code></pre>
  <p>I expect that there should be a better implementation of the same feature. Is there?</p>