Stack - C P P

Theory


  • LIFO (Last In First Out)
  • Operations
    • push, pop, peek, empty

STL Commands


  • #include <stack> => Header to include
  • stack<dataType> var => Initialize stack
  • var.push(val) => Insert value at top
  • var.pop() => Returns and removes the value from top
  • var.size() => Returns the size of stack
  • var.top() => Returns the top element
  • var.empty() => Returns boolean value true if stack is empty
Share: