title: C++ returning nested class with template on base class problem
body: <p>I am trying to create a list object, with the iterator class nested inside to understand how it works.
  In some method, I am trying to return an iterator object but it doesn't work.
  I created an example to show the problem :</p>
  
  <pre><code>// CLASS A
  template &lt;class T&gt;
  class A
  {
      public:
          class B;
          A(){}
  };
  
  // CLASS B
  template &lt;class T&gt;
  class A&lt;T&gt;::B
  {
      private:
          int varB;
  
      public:
          B(B&amp; b);
          B(const int&amp;);
          B returnThis();
  };
  
  template &lt;class T&gt;
  A&lt;T&gt;::B::B(const int&amp; value)
  {
      varB = value;
  }
  
  template &lt;class T&gt;
  A&lt;T&gt;::B::B(B&amp; b)
  {
      varB = b.varB;
  }
  
  template &lt;class T&gt;
  A&lt;T&gt;::B A&lt;T&gt;::B::returnThis()
  {
      return *this;
  }
  
  // MAIN
  
  void main()
  {
      A&lt;int&gt;::B classB(10);
  }
  </code></pre>
  
  <p>The error is near those lines:</p>
  
  <pre><code>template &lt;class T&gt;
  A&lt;T&gt;::B A&lt;T&gt;::B::returnThis()
  </code></pre>
  
  <p>The compiler tells me I am missing a ; before A::B::returnThis()</p>
  
  <p>I am trying to solve this problem for days and I can't find a way to make it work...
  I would really appreciate some help.
  Thanks in advance!</p>