Stack in C++
In this guide, we will learn the characteristics of dynamic structure in C++ called “stack”.
The stack is one of the varieties of a linked list. Access to its elements is only possible through its beginning, which is called the top of the stack. The stack works on the principle of “last in, first out” which is denoted by the acronym LIFO, and has the following properties:
- items are added to the top (head) of the stack;
- items are removed from the top (head) of the stack;
- the pointer to the last element of the stack is NULL;
- it is impossible to remove an item from the middle of the stack, not removing all the elements that go ahead.