From the course: C++ Templates and the STL

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Queue

Queue

- [Instructor] A queue is a container adaptor which is like a wrapper that uses an underlying container to hold its contents. The queue implements a first in first out queue where elements are pushed onto the back of the container and then popped from the front. Here I have a working copy of queue.cpp from chapter two of the exercise files and you'll notice that I include the queue header which contains the queue type. I'm also including the deque and list headers because we're going to use those as underlying containers. Here we're creating a queue from a list using the list as the underlying container. So first I create a list and I initialize it with an initializer list and then I construct a queue from that list and so I list as the two parameters to the template for the queue an integer type and a list of integers type. And then I pass the list to the constructor and this constructs the queue. And then I call report queue and report queue just reports the size and the front and…

Contents