previous | start | next

## Stacks and Queues

- A queue is similar to a stack, except that you add items to one end of the queue (the back) and remove them from the other end of the queue (the front).
- To visualize a queue, think of people lining up.
- Queues store items in a first in, first out or FIFO fashion.
- The standard queue template implements a queue in C++.

  >     queue<string> q;
  >     q.push("Tom");
  >     q.push("Dick");
  >     q.push("Harry");
  >     while (q.size() > 0)
  >     {
  >        cout << q.front() << "\n";
  >        q.pop();
  >     }

previous | start | next