3.12. Using a Queue in C++ΒΆ

Now we will turn our attention to using the queue data structure with the help of the Standard Template Library (STL) in C++.

As we described in Chapter 1, in C++, as in any object-oriented programming language, the implementation of choice for an abstract data type such as a queue is a class in which the queue operations are implemented as methods. Fortunately, the STL already has a well written implementation of the queue class.

In following queue implementation (ActiveCode 1) as push operations occur, new items are always added on the rear end of the queue and pop operations will manipulate the opposite side, the front end.

Self Check

Before you keep reading...

Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

You have attempted 1 of 4 activities on this page