Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Elem {
- public:
- int *num;
- Elem * prev;
- };
- class Stack {
- Elem * top;
- int arr;
- public:
- Stack() :arr(0) { top = new Elem; top->num = new int; };
- void push(int n){
- top->num[arr++] = n;
- }
- int pop(){
- return top->num[--arr];
- }
- ~Stack()
- {
- }
- };
- int main()
- {
- Stack obj;
- obj.push(23);
- obj.push(44);
- obj.push(55);
- cout << obj.pop() << endl;
- cout << obj.pop() << endl;
- cout << obj.pop() << endl;
- }
Add Comment
Please, Sign In to add comment