Wouldn't that destroy the whole purpose of a queue?
Imagine you're a teacher and you've got your class standing in a line in front of you outside your class. How would you remove all the sick pupils from the line? Remember that you can only interact with the pupil in front.
Maybe that analogy will help you answer the question.
BTW, how do one know that you have processed all the elements in the queue? There is no member to get the size of the queue. Unless this function they want is a friend, I can't see how.
Current algorithm:
For the number of items in the queue left not yet processed
Get the front element
Delete from the queue
If not the same as the one to remove
Add to the back of the queue
End if
End
Unless one use a temporary queue in the removeX function, which maybe clumsy.
Yes, I am clearing out the Q given in the parameter, and then only copy elements not equal to x to the new Q. Then I assign the new Q to the old. I can do this because the parameter is not a constant reference. The method signature is as given by the assignment question, so I guess I am not breaking any rules.