title: Template class compilation "expected constructor, destructor, or type conversion before ‘<’ token" error
body: <p>I'm having trouble with compiling my template class. This is my list.cpp</p>
  
  <pre><code>using namespace std;
  
  template &lt;class T&gt;
  List&lt;T&gt;::List()
  {
      length = 0;
  }
  
  template &lt;class T&gt;
  List&lt;T&gt;::~List()
  {
  
  }
  
  
  template &lt;class T&gt;
  List&lt;T&gt; &amp; List&lt;T&gt;::operator=(const List&lt;T&gt; &amp; rhs)
  {
      List&lt;T&gt; hha;
      return hha;
  }
  
  
  template &lt;class T&gt;
  int List&lt;T&gt;::size()
  {
      return length;
  }
  </code></pre>
  
  <p>ANd this is my list.h</p>
  
  <pre><code>#ifndef _LIST_H_
  #define _LIST_H_
  
  #include &lt;iterator&gt;
  #include &lt;ostream&gt;
  
  using namespace std;
  
  template &lt;class T&gt;
  class List
  {
      private:
  
          class ListNode
          {
              public:
                  ListNode();
                  ListNode(const T element);
  
                  ListNode *next;
                  T data;
          };
  
      public:
  
          // big3
          List();
          ~List();
          List&lt;T&gt; &amp; operator=(const List&lt;T&gt; &amp; rhs);
  
          int size();
          bool empty();
          void print(ostream &amp; os) const;
  
  
      private:
          ListNode * head;
          ListNode * tail;
          int length;
  };
  
  #include "list.cpp"
  
  #endif
  </code></pre>
  
  <p>when I run g++ list.cpp</p>
  
  <p>I get errors </p>
  
  <p>expected constructor, destructor, or type conversion before ‘&lt;’ token</p>
  
  <p>for definitions of constructor, destructor, and operator...</p>
  
  <p>I don't know what seems to be wrong</p>