/*
    Stacks are ideal for adding and removing at the end of the stack.
    Last-in First out  LIFO access.
    http://www.cplusplus.com/reference/stack/stack
*/

#include <stack>              // Stack
#include <iostream>           // cin/cout
using namespace std;

int main()
{
    stack<int> numbers;
    
    for (int i=1;i<=64;i*=2) 
      {
         cout << "Pushing " << i << " onto the stack" << endl;
         numbers.push(i);
      }
      
    cout << "The stack contains " << numbers.size() << " elements" << endl;

    cout << "Popping out elements...";
    while (!numbers.empty())
      {
         cout << ' ' << numbers.top();
         numbers.pop();
      }
    cout << endl;

    return 0;
}

