Push value to queue and pop value out of queue - C++ STL

C++ examples for STL:queue

Description

Push value to queue and pop value out of queue

Demo Code

#include <iostream> 
#include <queue> // queue adapter definition 
using namespace std; 

int main() /*from ww  w  .ja  va2  s  . c om*/
{ 
    queue< double > values; // queue with doubles 

    // push elements onto queue values 
    values.push( 3.2 ); 
    values.push( 9.8 ); 
    values.push( 5.4 ); 

    cout << "Popping from values: "; 

    // pop elements from queue 
    while ( !values.empty() ) 
    { 
        cout << values.front() << ' '; // view front element 
        values.pop(); // remove element 
    }

    cout << endl; 
}

Result


Related Tutorials