C++ call std::list of objects instead of C linked list
Based on your answer and the comments from @user673679, with some modifications:


Removing using namespace std.
Using unique_ptr to transparently handle object allocation and deallocation. Remember to create items with make_unique.
forward_list is just fine for a FIFO queue.


Note that I don't use a range-based for loop because I only iterate the list once (run function and remove element).

#include "ctask.h" // Ctask, Ca and Cb definitions
#include &lt;forward_list&gt;
#include &lt;iterator&gt;
#include &lt;memory&gt;

class TaskQueue {
public:
   TaskQueue() :
     _tasks(),
     _last( _tasks.before_begin() )
   {
   }

   ~TaskQueue() = default;

   void add( std::unique_ptr&lt;Ctask&gt;&amp;&amp; t ) {
     _last = _tasks.insert_after( _last, std::move(t) );
   }

   void run_all() {
     task_list::iterator prev = _tasks.before_begin();
     task_list::iterator curr = _tasks.begin();
     while( curr != _tasks.end() ) {
        (*curr)-&gt;run();
        curr = _tasks.erase_after(prev);
     }
     _last = prev;
   }

private:
   typedef std::forward_list&lt;std::unique_ptr&lt;Ctask&gt;&gt; task_list;
   task_list           _tasks;
   task_list::iterator _last;
};

int main(void) {
    TaskQueue queue;
    queue.add(std::make_unique&lt;Ca&gt;());
    queue.add(std::make_unique&lt;Cb&gt;());
    queue.run_all();
    return 0;
}


Edit: I realized that you can make run_all more readable since you are basically removing all the elements from the queue, so that the while loop doesn't actually depend on _last value. The simplified function would be:

   void TaskQueue::run_all() {
     while( !_tasks.empty() ) {
        _tasks.front()-&gt;run();
        _tasks.pop_front();
     }
     _last = _tasks.before_begin();
   }