When i print data stored in a queue it also dequeue these data...
can someone provide me hints on how to print data without dequeue...printing
should only display data stored in that queue........

Recommended Answers

All 3 Replies

Have you tried copying your Queue into a temporary Queue, and printing the data of the temporary Queue instead?

Actually, the smarter solution would be to return an iterator of the Queue and traverse through it and get the output of the data inside.

Yeap, Copy the pointer to the first node. And move it to the last node and print the data as you traverse.
And did you really understand how your dequeue algorithm works?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.