A stack is a data structure for FIFO (first in the last Out,filo), and the use of stacks requires the introduction of header file #include<stack>. The stack does not provide traversal functionality, nor does it provide an iterator, which has only one exit, as shown in the form.
constructor function
| Function prototypes |
Function |
| Stack<t> StkT |
Stack is implemented as a template class, and the default constructor for stack objects |
| Stack (const stack &stk) |
Copy constructor |
Assign value
| Function prototypes |
Function |
| stack& operator= (const stack &stk) |
Overloaded equals operator |
Basic operations
| member functions |
Function |
| Push (Elem) |
Add a elem element to the top of the stack |
| Pop () |
Remove the first element from the top of the stack |
| Elem Top () |
Returns the top element of the current stack |
| BOOL Empty () |
Evaluates if the stack is empty, the stack null returns TRUE, otherwise returns false |
| int size () |
Returns the number of elements in the stack |
C + + STL stack