C++ Generic Queue

I want to share with you a generic queue in C++ that I made for educational purposes. It is mainly composed by two classes as every LIFO stack (also known as Queue), first the Queue class that defines an interface for using our queue with the common methods (enqueue, dequeue, first, isEmpty,…) and finally the Node class that represents a node of information with a pointer to the next element.

In order to have a Generic Queue we need to parametrize that classes and if necessary, override the assignment method if we want to use a non primitive type queue.

Note: Implementation of methods must be in headers files instead of .cpp files otherwise we can get some compiler errors (tested in Visual Studio 2010)

Queue class code:

Node class code:

You can download the full project for Visual Studio 2010 from: GenericQueue

Tagged with: , , , , ,
One comment on “C++ Generic Queue
  1. Devtropia says:

    Simple y elegante, gracias.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.