title: Copy assignment operator overloading of a class template
body: <p>When I try to overload the copy constructor, it gives me the following error code.<br>
  I encountered similar error message when I was trying to overload the &lt;&lt; operator.</p>
  
  <p>I fixed it by defining inside header</p>
  
  <p>However, this time the same trick does not work..</p>
  
  <p>How do I fix this and What is really going on to cause this error message?</p>
  
  <p>Here is my copy constructor definition</p>
  
  <pre><code>template &lt;class ItemType&gt;
  void List342&lt;ItemType&gt;::operator=(List342 &amp;source)
  {
  Node *sNode, *dNode, *insNode;
  
  if (this == &amp;source) return;
  
  this-&gt;Clear();
  if (source.head == NULL)
  {
      return;
  }
  dNode = new Node;
  dNode-&gt;value = (source.head)-&gt;value;
  this-&gt;head = dNode;
  sNode = (source.head)-&gt;next;
  while (sNode != NULL)
  {
      insNode = new Node;
      insNode-&gt;value = sNode-&gt;value;
      dNode-&gt;next = insNode;
      dNode = dNode-&gt;next;
      sNode = sNode-&gt;next;
  }
  }
  </code></pre>
  
  <p>And here is my header file.</p>
  
  <pre><code>#ifndef LIST342_H_
  #define LIST342_H_
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  template &lt;class ItemType&gt;
  class List342 {
  
  friend ostream&amp; operator&lt;&lt;(ostream &amp;outStream, const List342 &amp;list)
  {
      Node *pNode;
  
      pNode = list.head;
      while (pNode != NULL)
      {
          outStream &lt;&lt; *pNode-&gt;data;
          pNode = pNode-&gt;next;
      }
      return outStream;
  }
  
  public:
  List342();
  List342(List342&lt;ItemType&gt; &amp;);
  ~List342();
  
  bool BuildList(string FileName);
  bool Insert(ItemType *obj);
  bool Remove(ItemType target, ItemType &amp;result);//check
  bool Peek(ItemType target, ItemType &amp;result);//check
  bool isEmpty();
  void ClearList();
  bool Merge(List342 &amp;list1, List342 &amp;list2);
  
  List342 operator+(const List342 &amp;list) const;
  List342 operator+=(const List342 &amp;list);
  
  bool operator==(const List342 &amp;list) const;
  bool operator!=(const List342 &amp;list) const;
  
  void operator=(List342 &amp;);
  
  private:
  struct Node {
      ItemType *data;
      Node *next;
  };
  Node *head;
  };
  #endif /* LIST342_H_ */
  </code></pre>