Test queue method: push(), empty(), front(), pop() - C++ STL

C++ examples for STL:queue

Description

Test queue method: push(), empty(), front(), pop()

Demo Code

#include <iostream>
#include <string>
#include <queue>
#include <stack>
using namespace std;
int main()/*from  w  w  w . j av  a2 s  .co  m*/
{
   // Demonstrate queue.
   queue<string> q;
   cout << "Demonstrate a queue for strings.\n";
   cout << "Pushing one two three four\n";
   q.push("one");
   q.push("two");
   q.push("three");
   q.push("four");
   cout << "Now, retrieve those values in FIFO order.\n";
   while(!q.empty()) {
      cout << "Popping ";
      cout << q.front() << "\n";
      q.pop();
   }
   cout << endl;
   return 0;
}

Result


Related Tutorials