title: Dequeue function not outputting proper values
body: <p>There seems to be an issue with my <code>dequeue</code> function within a queue class that I have. My <code>dequeue</code> function which is part of the position class, is not returning the correct values that have been enqueued into the list.</p>
  
  <p>The values that have been enqueued are which is a position object, are 2,1 and -1, but when I dequeue that object i get 2,506216, and -1; When I assign the <code>*pos</code> ponter to an object I am left with the default values;The enqueue function seems to be working correctly for when I check the <code>ptr</code> values they are correct.</p>
  
  <pre><code>//position constructor
  front = back = &amp;header;
  
          struct Posnode
          {   
             Position *pos;
             Posnode *next;    
          };
      class Position
      private:
                Posnode *front,*back,header;
  void Position::dequeue(Position&amp;p)
  {
      Posnode *ptr=front-&gt;next;
      front-&gt;next = ptr-&gt;next;
      p = *ptr-&gt;pos;
      p.geta();//checking for values but am left with the default
  
      if (back == ptr)
      {
          back = front;
      }
      delete ptr;
  
  }
  v
  
  oid Position::enqueue(Position n) //assigning Position object to end of queue
      {
          Posnode *ptr = new Posnode;
          ptr-&gt; pos =  &amp;n;
          back-&gt;next = ptr;
          back = ptr;
  
          return;
      }
  </code></pre>
  
  <p>Position copy,intial(5);
          copy = intial;</p>
  
  <pre><code>        if (copy.ismovelegal(posmoves, r))
          {
              copy.makemove(posmoves, r);
  
  
              if (intial.solved(copy))
              {
                  cin.get();
              }
              else
              {
                  p.enqueue(copy);
  
  
              }
          }
          copy.free();//clearing object private memebers
      }
      intial.free();
  
      p.dequeue(o);//copy that was previous enqued is not enqued
      o.geta();
  </code></pre>