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

You have attempted of activities on this page