• Source
    1. /* Queue follows FIFO structure. It means First Input First Output */
    2.  
    3. #include<iostream>
    4. #include<queue>
    5. using namespace std;
    6.  
    7. int main()
    8. {
    9.  
    10. int i=52;
    11. queue<int> q; // you can write double / string type queue also
    12.  
    13. q.push(50);
    14. q.push(62);
    15. q.push(14);
    16. q.pop(); // it will pop first number 50
    17. q.push(i);
    18.  
    19.  
    20. printf("The size of queue is now %d\n\n", q.size() );
    21.  
    22. while( !q.empty() ){ // if not empty then continue
    23. printf("-> %d\n", q.front() );
    24. q.pop();
    25.  
    26. }
    27. printf("\n\t\t*** Thanks ...\n");
    28. getchar();
    29. return 0;
    30. }
    31.  
    32. /*
    33. In the same way, you can use Stack
    34.  
    35.  
    36. #inlcude<stack>
    37.  
    38.   // Declare:
    39.   stack<double> s; // now, write your code . . .
    40.  
    41. // In same way you can use Priority queue
    42.   // Declare
    43.   priority_queue<int > q; // now, write your code . . .
    44.  
    45. */
    46.