Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

queue stl

//GET FULL KNOWLWEDGE OF QUEUE IN STL ALONG WITH LINE TO LINE EXPLAINATION


#include <iostream>
// this line include queue
#include <queue>
using namespace std;
// Print the queue 
// queue<int> q  , q is queue of integers
void print_queue(queue<int> q)
{
// run while loop untill q is empty and stop when queue become empty
    while (!q.empty()) 
    {
        cout << q.front() << " ";
        q.pop();
    }
        cout << '
';
}

int main()
{
  queue<int> q;
  q.push(1);
  q.push(2);
  q.push(3);
  print_queue(q);
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #queue #stl
ADD COMMENT
Topic
Name
5+5 =