I'm trying to pass objects by value between threads with a queue.
Because there are multiple different objects, I made an abstract class.
class message
{
public :
virtual ~message(){};
};
then I have a subclass for each different type of message
class a_specific_message : public message
{
...
};
I read this tutorial for implementing the queue and I call it the following way:
concurrent_queue<message> queue;
a_specific_message m{1, 2, 3};
queue.push(m);
My problem is that I need to override the operator=
so the queue can clone the message
popped_value=the_queue.front();
I tried to add a virtual operator but it doesn't get called in the subclass.
I don't know how I could achieve something like this without passing object by reference.