A simple stack example: push, empty, pop and top : Stack « Data Structure « C++






A simple stack example: push, empty, pop and top

A simple stack example: push, empty, pop and top
#include <iostream>
#include <stack>
using namespace std;

int main()
{
  stack<char> stackObject;

  stackObject.push('A');
  stackObject.push('B');
  stackObject.push('C');
  stackObject.push('D');

  while(!stackObject.empty()) {
    cout << "Popping: ";
    cout << stackObject.top() << endl;
    stackObject.pop();
  }

  return 0;
}


           
       








Related examples in the same category

1.A four-function postfix calculator.A four-function postfix calculator.