

#include <iostream>

using namespace std;  //introduces namespace std

class Node {
	private: 
		Node * next;
		int value;
	public:
		int getValue() {return value;}
		void setValue(int inValue) { value = inValue;}
		Node* getNext() {return next;}
		void setNext(Node* inNext) { next = inNext;}
		Node(Node* inNext, int inValue) { next = inNext; value =
inValue;}
};

class stack {
	private: 
		Node* top;
	public:
		stack(){
			top = NULL;
		}
		
		void push(int inValue) {
			top = new Node(top, inValue);
		}
		
		int pop() {
			int value;
		
			if (top == NULL) {
				cout << "stack underflow error";
			}
			else {
				Node* oldtop = top;
				value = top->getValue();
				top = top->getNext();
				delete oldtop;
			}
			
			return value;
		}
};

int main() {
	stack s;
	s.push(3);
	s.push(4);
	cout << s.pop();
}

