title: Templates and nested classes/structures
body: <p>I have a simple container :</p>
  
  <pre><code>template &lt;class nodeType&gt; list {
      public:
          struct node {
              nodeType info;
              node* next;
          };
  
      //...
  };
  </code></pre>
  
  <p>Now, there is a function called <code>_search</code> which searches the list and returns a reference to the node which matched. Now, when I am referring to the return-type of the function, I think it should be <code>list&lt;nodeType&gt;::node*</code>. Is this right? When I define the function inline, it works perfectly:</p>
  
  <pre><code>template &lt;class nodeType&gt; list {
      public:
          struct node {
              nodeType info;
              node* next;
          };
  
          node* _search {
              node* temp;
              // search for the node
              return temp;
          }
  };
  </code></pre>
  
  <p>But, if I define the function outside the class,</p>
  
  <pre><code>template &lt;class nodeType&gt; list&lt;nodeType&gt;::node* list&lt;nodeType&gt;::_search() {
      //function
  }
  </code></pre>
  
  <p>it doesn't work. The compiler gives an error saying <code>Expected constructor before list&lt;nodeType&gt;::_search</code> or something. The error is something similar to this. I don't have a machine on which I can test it currently.</p>
  
  <p>Any help is sincerely appreciated.</p>