title: How to use a nested struct/class type as a return value, in a template class?
body: <p>I currently writing some BST template class as execise
  but a promblem I met confuses me.</p>
  
  <p>Here is my code written in a header file
  I only paste the part that causes the error here</p>
  
  <pre><code>template&lt;typename Type&gt;
  class TestCls
  {
      struct Node
      {
          Type data;
          Node* LeftChild;
          Node* RightChild;
      };
      Node* pRoot;
  public:
      Node* GetNode(Node*&amp; someroot);
  };
  
  template&lt;typename Type&gt;
  Node * TestCls&lt;Type&gt;::GetNode(Node*&amp; someroot)
  {
      return NULL;
  }
  </code></pre>
  
  <p>I use VS2015 to compile it, then the errors as below:</p>
  
  <p>Error   C2059   syntax error: '' 
  Error   C2923   'TestCls': 'Type' is not a valid template type argument for parameter 'Type'<br>
  Error   C2923   'TestCls': 'Type' is not a valid template type argument for parameter 'Type'<br>
  Error   C2065   'Type': undeclared identifier<br>
  Error   C2065   'Type': undeclared identifier</p>
  
  <p>It seems the '<code>Node *</code>' in the head of the <code>GetNode()</code> function's definition isn't recognized by the compiler.</p>
  
  <p>However if I use auto return type like this:</p>
  
  <pre><code>auto TestCls&lt;Type&gt;::GetNode(Node*&amp; someroot)-&gt;Node*&amp;
  {
      return NULL;
  }
  </code></pre>
  
  <p>The code will be compiled successfully.</p>
  
  <p>So what's wrong in the first version?
  How I properly use a nested struct/class type as a return value?</p>