title: Usage of typename in typedef versus inheritance
body: <p>Just wondering about C++ <code>typename</code>, used to tell the parser that some symbols are types. Why must we use it after <code>typedef</code> and not for inheritance?</p>
  
  <p>Example: imagine you have this</p>
  
  <pre><code>struct C { /* a class */ }; 
  template&lt;class T&gt; struct S {
     typedef C type; // S&lt;T&gt;::type is a type
  };
  </code></pre>
  
  <p>What's bothering me is this:</p>
  
  <pre><code>template&lt;class T&gt; struct Typedef {
     typedef typename S&lt;T&gt;::type MyType; // needs typename
  };
  template&lt;class T&gt; struct Inheritance
     :  S&lt;T&gt;::type                       // doesn't need typename
  { };
  </code></pre>
  
  <p>In both cases the parser should expect a type, so it could parse <code>S&lt;T&gt;::type</code> as one. Why does it only do so for inheritance, and not for typedefs? The pattern seems the same to me:</p>
  
  <pre><code>typedef $type$ $new_symbol$;
  class $new_symbol$ : $type$ { $definition$ };
  </code></pre>
  
  <p>Or is there a usage of <code>typedef</code> I'm not aware of, which make this ambiguous?</p>
  
  <p>PS: I'm pretty sure this has already been asked, but I can't find it (there's a lot of noise related to the <code>typename</code> keyword). This question is only about the syntax, not whether it's better to use inheritance or typedefs. I appologize in advance if there's a duplicate.</p>