title: need ‘typename’ before ‘..’ because ‘..’ is a dependent scope
body: <p>having trouble when trying to compile a template class. </p>
  
  <p>In the .h file</p>
  
  <pre><code>template &lt;typename dataType&gt;
  class Node {    
   private:
      dataType nodeData;
      Node&lt;dataType&gt;* nextLink;
      Node&lt;dataType&gt;* previousLink;
   public:    
      Node(const dataType&amp; nodeData);
  
     // methods
  </code></pre>
  
  <p>In the .template file</p>
  
  <pre><code>template &lt;typename dataType&gt;
  Node&lt;dataType&gt;::dataType Node&lt;dataType&gt;::getData() const {
      return nodeData;
  };
  </code></pre>
  
  <p>The error I get when trying to compile is:</p>
  
  <pre><code> need ‘typename’ before ‘Node&lt;dataType&gt;::dataType’ because ‘Node&lt;dataType&gt;’ is a dependent scope
  
   Node&lt;dataType&gt;::dataType Node&lt;dataType&gt;::getData() const {
  </code></pre>
  
  <p>So then I add typename and it then gives me this error:</p>
  
  <pre><code>error: expected nested-name-specifier before ‘dataType’
         typename dataType getData() const;
                  ^
  error: expected ‘;’ at end of member declaration
  error: declaration of ‘int Node&lt;dataType&gt;::dataType’
  error: shadows template parm ‘class dataType’
         template &lt;typename dataType&gt; 
                   ^
  </code></pre>
  
  <p>What have I done wrong?</p>