Stack
The std::stack
follows the LIFO principle (Last In First Out). The stack sta
, which needs the header <stack>
, has three special methods.
With sta.push(e)
you can insert a new element e
at the top of the stack, remove it from the top with sta.pop()
and reference it with sta.top()
. The stack supports the comparison operators and knows its size. The operations of the stack have constant complexity.