Put string into a queue : queue « Queue Stack « C++






Put string into a queue

  
#include <iostream>
#include <string>
#include <queue>
#include <stack>

using namespace std;

int main()
{
   cout << "FIFO order:\n";

   queue<string> q;
   q.push("A");
   q.push("B");
   q.push("C");

   stack<string> s;
   while (q.size() > 0)
   {
      string name = q.front();
      q.pop();
      cout << name << "\n";
      s.push(name);
   }

   cout << "LIFO order:\n";

   while (s.size() > 0)
   {
      cout << s.top() << "\n";
      s.pop();
   }

   return 0;
}
  
    
  








Related examples in the same category

1.queue with doubles
2.queue: push, pop, front and size
3.queue.front()
4.Queue: push, pop and size
5.Queue of string: push(), empty(), front(), pop()