Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include "linkedListStack.h"
- using namespace std;
- //constructor implementation
- linkedListStack::linkedListStack():top(NULL) {
- void push(int v)
- {
- listNode *newNode = new listNode;
- newNode->value = v;
- newNode->next = top;
- top = newNode;
- cout<<"Pushed "<< newNode->data << endl << newNode->next << endl;
- }
- int pop()
- {
- if (isEmpty())
- {
- throw string("Stack is empty");
- }
- listNode *newNode = new listNode;
- newNode = top;
- top = newNode->next;
- cout<<"Popped "<< newNode->data << endl;
- delete newNode;
- };
- bool isEmpty()
- {
- return (top == NULL);
- }
- }
- //destructor
- linkedListStack::~linkedListStack() {
- cout << "Stack has been deleted" << endl;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement