I'm guessing that when the queue is empty then I do what I'm already doing. But, when the queue has one element, that element's next points to that element again?
Then, when I insert 2nd element, things start to change as they should, and I always move myBack to the last place?
void Queue::enqueue(const QueueElement & value)
{
//allocate memory for new element
Queue::NodePointer newptr = new Queue::Node(value);
//if list is empty, this is our only element, its NEXT points to itself
if(empty())
{
myBack = newptr;
myBack->next = myBack;
}
else
{
//new elements NEXT will point to current TOP
newptr->next = myBack->next;
//put new element after current myBack
myBack->next = newptr;
//change myBack so that it points to new "newest" element
myBack = myBack->next;
}
}