Demonstrate the queue class: push, front, empty and pop : Queue « Data Structure « C++






Demonstrate the queue class: push, front, empty and pop

Demonstrate the queue class: push, front, empty and pop


#include <iostream>
#include <queue>
#include <string>
using namespace std;

int main()
{
  queue<string> queueObject;

  cout << "Pushing one two three four\n";
  queueObject.push("one");
  queueObject.push("two");
  queueObject.push("three");

  while(!queueObject.empty()) {
    cout << "Popping ";
    cout << queueObject.front() << endl;
    queueObject.pop();
  }

  return 0;
}

           
       








Related examples in the same category

1.Queue: push and popQueue: push and pop
2.Cycling through a queue.Cycling through a queue.
3.Define our own Queue classDefine our own Queue class
4.Define a queueDefine a queue
5.Your own Queue classYour own Queue class