Use of typename for vector iterator - C++11 example
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords">Where and why do I have to put the &ldquo;template&rdquo; and &ldquo;typename&rdquo; keywords?</a>  </p>
</blockquote>



<p>This is reproduced from <a href="http://www2.research.att.com/~bs/C++0xFAQ.html" rel="nofollow">Stroustroup's FAQ</a>.  I've seen typename used when you don't know the type, for instance in templates, <code>template &lt;typename&gt; class some_class</code>.  Why is typename used in the example below?</p>

<pre><code>    template&lt;class T&gt; void printall(const vector&lt;T&gt;&amp; v)
    {
        for (auto p = v.begin(); p!=v.end(); ++p)
            cout &lt;&lt; *p &lt;&lt; "\n";
    }

In C++98, we'd have to write 

    template&lt;class T&gt; void printall(const vector&lt;T&gt;&amp; v)
    {
        for (typename vector&lt;T&gt;::const_iterator p = v.begin(); p!=v.end(); ++p)
            cout &lt;&lt; *p &lt;&lt; "\n";
    }
</code></pre>
