I am trying to print a queue
below. I have tried the idea of creating a temp queue
and writing into it then writing it back.
But it's not working.
Or what am I missing here?
for(int i = 1; i<myQueue.size(); i++)
{
queue<int> tempQueue;
cout << myQueue.front() << endl;
MytempQueue.push(myQueue.front());
myQueue.pop();
myQueue.push(myTempQueue.back());
}
My queue is queue<int> myQueue;
Essentially, I want to print this queue
without emptying it. But I am stuck here.