#include
#include
using namespace std;
int main()
{
// Empty stack
stack mystack;
mystack.push(0);
mystack.push(1);
mystack.push(2);
// Printing content of stack
while (!mystack.empty()) {
cout << ' ' << mystack.top();
mystack.pop();
}
}
O/P=
2 1 0
Note that output is printed on the basis of LIFO property
Eg
Input : mystack = 0, 1, 2
mystack.pop();
Output : 0, 1
Input : mystack = 0, 1, 2, 3, 4, 5
mystack.pop();
Output : 0, 1, 2, 3, 4