How do I deliver templates arguments to templated sub-class via inheritance?
<p>I have this code that uses a template parent class <code>A</code> that has one templated sub-class <code>C</code>. <code>A</code> takes a type (<code>T</code>) and <code>C</code> takes an object of that type (<code>T t</code>) in their template parameters. What I'm trying to do is, in the inheritance of the class <code>B</code>, give <code>C</code> its template arguments, make a <code>b</code> object, and call <code>C</code>'s <code>.h</code> member function. But I'm getting the following errors:</p>

<blockquote>
  <p>prog.cpp:10:44: error: too many template-parameter-lists<br>
  prog.cpp: In function <code>'int main()'</code>:<br>
  prog.cpp:14:5: error: <code>'B'</code> was not declared in this scope<br>
  prog.cpp:14:7: error: expected <code>';'</code> before <code>'b'</code></p>
</blockquote>

<pre><code>template &lt;typename T&gt; struct A {
    protected:
        template &lt;T&gt; struct C { 
            T h( T t ) { return t * t; }
        };
};

template &lt;typename T = int&gt; template &lt;T t = 5&gt; struct B : public A&lt;T&gt;::C&lt;t&gt; {};

int main() {

    B b;
    b.h();

}
</code></pre>

<p>The error is called when I instantiate a <code>B</code> object. I've tried changing a lot of things around but it didn't help the situation. For example, I changed:</p>

<pre><code>template &lt;typename T = int&gt; template &lt;T t = 5&gt; struct B...
</code></pre>

<p>to</p>

<pre><code>template &lt;typename T = int&gt; struct B...
</code></pre>

<p>and changed</p>

<pre><code>: public A&lt;T&gt;::C&lt;t&gt; {};
</code></pre>

<p>to</p>

<pre><code>: public A&lt;T&gt;::C&lt;T t = 5&gt; {};
</code></pre>

<p>But I received even more errors:</p>

<blockquote>
  <p>prog.cpp:10:53: error: non-template <code>'C'</code> used as template<br>
  prog.cpp:10:53: note: use <code>'A&lt;T&gt;::template C'</code> to indicate that it is a template<br>
  prog.cpp:10:66: error: expected <code>'{'</code> before <code>';'</code> token<br>
  prog.cpp: In function <code>'int main()</code>:<br>
  prog.cpp:14:7: error: missing template arguments before <code>'b'</code><br>
  prog.cpp:14:7: error: expected <code>';'</code> before <code>'b'</code><br></p>
</blockquote>

<p>I'm also curious about the first set of errors in which I got <code>B was not declared in this scope</code>. How could it not be? Is it the way I'm defining <code>B</code>? What could I be doing wrong?</p>
