I can see a few problems here. Please make these corrections and re-run:
1. Make packet_with_attributes* single_connection_per_user_queue :: dequeue_the_packet (packet_with_attributes* temp_head) static function; (I will explain the reason for this below)
2. As suggested before, get rid of these two lines:
old_temp_head1 = new packet_with_attributes;
old_temp_head2 = new packet_with_attributes;
and this line:
delete old_temp_head1;
within dequeue_the_packet() function.
Basically, forget about this. The function body should look like this (if I understand it correctly):
{
while (temp_head && temp_head->new_packet != NULL)
{
temp_head = temp_head->new_packet;
}
if(temp_head) temp_head->new_packet = NULL;
return temp_head;
}
3. Now, in the algorithm_dequeue_stage() function you need to change this line:
(q+i)->head = (q+i)->dequeue_the_packet ((q+i)->head);
to:
(q+i)->head = packet_with_attributes::dequeue_the_packet ((q+i)->head);
Now, let me explain the reason for making the function static. See, how you fiddling with the temp_head object you are passing to the function. At some stage the object may become NULL. This means that it will be invalid and if the function is called within this object there will be a crash.