1#include <bits/stdc++.h>
2
3stack<int> stk;
4stk.push(5);
5int ans = stk.top(5); // ans =5
6stk.pop();//removes 5
1// CPP program to illustrate
2// Implementation of push() function
3#include <iostream>
4#include <stack>
5using namespace std;
6
7int main()
8{
9 // Empty stack
10 stack<int> mystack;
11 mystack.push(0);
12 mystack.push(1);
13 mystack.push(2);
14
15 // Printing content of stack
16 while (!mystack.empty()) {
17 cout << ' ' << mystack.top();
18 mystack.pop();
19 }
20}
21