title: help with linked list template
body: <p>I need some help with my linked list.  I think the problem is in the copy constructor or the assignment overload. it keeps giving my segmentation fault when i call: 
  (Queue test_int_copy(test_int);)
  Any other error or poor implementation that you can see would also be very helpful.
  the .h file</p>
  
  <pre><code>#ifndef QUEUE_H
  #define QUEUE_H
  
  template &lt;class Object&gt;
  class Queue
  {
   public:
       Queue();
       //initializes empty queue
  
       Queue(const Queue&amp; a_queue);
       //copy constructor
  
       Queue&amp; operator =(const Queue&amp; rhs);
       //overload assignment operator
  
       bool enqueue(const Object&amp; d);
       //insert object into queue,return true
       //return false if not
  
       bool dequeue(Object&amp; d);
       //remove object from queue,return true
       //if empty return false
  
       bool isEmpty();
       //check if empty
  
       ~Queue();
       //destructor
  
  private:
      struct ListNode
      {
          Object obj;
          //object that is in the list
  
          ListNode *next;
          //pointer to the next node
  
      };
      //struct of list
  
      ListNode *head;
      //pointer that points to head
  };
  
  #endif //Queue_H
  #include "queue.cpp"  //include queue.cpp with file
  </code></pre>
  
  <p>the .cpp file</p>
  
  <pre><code>     #include &lt;iostream&gt;
  using namespace std;
  
  template &lt;class Object&gt;
  Queue&lt;Object&gt;::Queue()
  {
      head = NULL;
  }
  
  template &lt;class Object&gt;
  Queue&lt;Object&gt;::Queue(const Queue&lt;Object&gt; &amp;a_queue)
  {
      head = NULL;
    ListNode *nodePtr = a_queue.head;
      while (nodePtr){
        enqueue(nodePtr-&gt;obj);
        nodePtr = nodePtr-&gt;next;
      }
  
  }
  
  template &lt;class Object&gt;
  Queue&lt;Object&gt;&amp; Queue&lt;Object&gt;::operator =(const Queue&lt;Object&gt; &amp;rhs)
  {
      //head = NULL;
    ListNode *nodePtr = rhs.head;
    Object temp;
      while(head){
        dequeue(temp);
      }
      while (nodePtr){
        enqueue(nodePtr-&gt;obj);
        nodePtr = nodePtr-&gt;next;
      }
  }
  
  template &lt;class Object&gt;
  bool Queue&lt;Object&gt;::enqueue (const Object&amp; d) //Enqueue
  {
      ListNode *newNode = new ListNode;
      newNode-&gt;obj = d;
      newNode-&gt;next = NULL;
      ListNode *nodePtr = NULL;
      ListNode *previousNode = NULL;
  
      if(isEmpty()){
          head = newNode;
          return true;
          }
      else{
          nodePtr = head;
          while(nodePtr != NULL){
              previousNode = nodePtr;
              nodePtr = nodePtr-&gt;next;
          }
          if(previousNode-&gt;next == NULL){
              previousNode-&gt;next = newNode;
              return true;
          }
          else
              return false;
      }
  }
  
  template &lt;class Object&gt;
  bool Queue&lt;Object&gt;::dequeue (Object&amp; d)  //Dequeue
  {
      ListNode *nodePtr;
  
      if(!head)
          return false;
      else{
        if(head-&gt;next != NULL){
              nodePtr = head;
              d = nodePtr-&gt;obj;
              head = head-&gt;next;
              delete nodePtr;
              return true;
        }
        else{
          d = head-&gt;obj;
          head = NULL;
          return true;
        }
      }
  }
  
  
  template &lt;class Object&gt;
  bool Queue&lt;Object&gt;::isEmpty() //Check if Empty
  {
      if(!head)
          return true;
      else
          return false;
  }
  
  template &lt;class Object&gt;
  Queue&lt;Object&gt;::~Queue()   //Destructor
  {
      Object temp;
      while(head)
          dequeue (temp);
  }
  </code></pre>