title: Is there a way to move a pointer from a queue to another?
body: <p>I need to take a pointer to an object stored in one queue, process it, and move to another queue that is in another object. Following, I'll show the structure (schematically) of the problem.</p>
  <pre><code>class A{
    public:
      A();
      ...
      // fields and methods
  }
  
  class B : public A{
    public:
      B();
      ...
      // extra fields and methods (not in A)
      
  }
  class C : public A{
    public:
      C();
      ...
      // extra fields and methods (not in A)
      
  }
  
  
  class Sender{
    public:
      Sender();
      std::queue&lt;A*&gt; qSender;
      ...
      // fields and methods
  }
  
  class Receiver{
    public:
      Receiver();
      std::queue&lt;A*&gt; qReceiver;
      void moveToReceiver(Sender&amp; s, int n);
      ...
      // fields and methods
  }
  
  </code></pre>
  <p>I've used the queue with pointer to base class to overcome the slicing object problem, but I don't know if is the best way to do. I've filled the <code>qSender</code> queue following the</p>
  <p><code>qSender.push_back(new B(...)));</code></p>
  <p>Then i've tried to move from a qSender to qReveiver with this code:</p>
  <pre><code>void moveToReceiver(Sender&amp; s, int n){
    for(int i = 0; i &lt; n; i++){
      A* a = senderObject.qSender.front();
      senderObject.qSender.pop();
      qReceiver.push(a);
    }
  }
  
  </code></pre>
  <p>But I've noticed that the elements are not being pop; the code is only &quot;moving&quot; <code>n</code> pointers to the first object to the <code>qReceiver</code> and not removing from  <code>qSender</code>.</p>
  <p>Any ideas to solve that are welcome.</p>