The std::stack class is a container adapter in C++ that gives the programmer the functionality of a stack - specifically, a LIFO (last-in, first-out) data structure.
std::stack
is defined in the Standard Library header <stack>
:
template<class T, class Container = std::deque<T>> class stack;
The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The stack pushes and pops the element from the back of the underlying container, known as the top of the stack.
Reference: https://en.cppreference.com/w/cpp/container/stack