Creating a Generic Queue
Armed with this new template knowledge, we can now attempt to create something practical. In coming chapters, we will cover the containers from the STL, but before that, it is useful to have an idea of how some of them may work on a simpler level. Then, if thesituation arises that one of them is not quite right for our needs, we can write something more suited to us that still gives us the nice-to-use interface of the STL.
What Is a Queue?
We can define a queue as a container with a first in, first out (FIFO) data structure. Elements are inserted at the back and deleted from the front. Queues are useful for many things, such as scheduling tasks that can be acted upon and then removed. Think of queues just like when you queue in a shop. If you are first in the queue, then you will be served first.
For our example, we will be basing our queue on the STL queue and trying to implement everything that it provides already. That being said, the STL queue...