Guest User

Untitled

a guest
Oct 1st, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class Elem {
  4. public:
  5.     int *num;
  6.     Elem * prev;
  7. };
  8.  
  9. class Stack {
  10.     Elem * top;
  11.     int arr;
  12. public:
  13.     Stack() :arr(0) { top = new Elem; top->num = new int; };
  14.     void push(int n){
  15.         top->num[arr++] = n;
  16.     }
  17.     int pop(){
  18.         return top->num[--arr];  
  19.     }
  20.     ~Stack()
  21.     {
  22.     }
  23. };
  24.  
  25. int main()
  26. {
  27.     Stack obj;
  28.     obj.push(23);
  29.     obj.push(44);
  30.     obj.push(55);
  31.     cout << obj.pop() << endl;
  32.     cout << obj.pop() << endl;
  33.     cout << obj.pop() << endl;
  34. }
Add Comment
Please, Sign In to add comment