Wednesday, May 11, 2011

STL queue example

Here's a simple STL queue example code in c++. It just shows how to push and pop data in STL queue object. [STL queue example]

// A simple example of putting three items into a queue and
// then taking them off the queue.
#include <iostream.h>
#include <list>
#include <queue>
int main()
{
queue<char> q;
q.push('a');
q.push('b');
q.push('c');
cout << q.front();
q.pop();
cout << q.front();
q.pop();
cout << q.front();
q.pop();
}