Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename S>
- class Level {
- public:
- S item;
- Level* next;
- Level(S it, Level* stk) {
- item = it;
- next = stk;
- }
- ~Level() {
- delete next;
- }
- };
- template<typename T>
- class Stack {
- public:
- Level<T>* top;
- Stack() {
- top = NULL;
- }
- void push(T item) {
- top = new Level<T>(item, top);
- }
- T pop() {
- T item = top->item;
- this->top = top->next;
- return item;
- }
- ~Stack() {
- delete top;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement