The stack abstract data type or stack ADT is defined by the following structure and operations. A stack is structured, as described above, as an ordered collection of items where items are added to and removed from the end called the “top.” Stacks are ordered LIFO. The stack operations are given below.
stack<datatype> creates a new stack that is empty. It needs no parameters and returns an empty stack. It can only contain a certain type of data. e.g. int, string etc.
For example, if s is a stack that has been created and starts out empty, then Table 3.4.1 shows the results of a sequence of stack operations. Under stack contents, the top item is listed at the far right.