
#include <iostream>

using namespace std;

class node {
	protected:
		node * next;
	public:
		node (node * inNext) {
			next = inNext;
			cout << "you have created a node object\n";
		}
		
		node() {
			cout << "you have created a node\n";
		}
		
		~node() {
			cout << "you have destructed a node\n";
		}
		
		node * getNext() { return next;}
		void setNext(node * inNext) {next = inNext;}
	};
		
class intNode : public node {
	private:
		int value;
	public:
		int getValue () {return value;}
		void setValue(int inValue) { value = inValue;}
		
		intNode(int inValue, node * inNext) {
			cout << "you have created an intNode\n";
			value = inValue;
			next = inNext;
			
		}
		
		~intNode() {
			cout << "you have destructed a intNode\n";
		}
		
		intNode() {
			cout << "you have created an intNode\n";
		}			

};

class stack {
	private:
		node * top;
	public:
		stack() { 
			cout << "you constructed the stack\n";
			top = NULL;}
			
		~stack() {
			while (top != NULL) {
				pop();
			}
			cout << "you have destructed the stack\n";
		}
		
		void push () {
			cout << "you are pushing the stack\n";
			top = new node(top);
		}
		
		void pop() {
			cout << "you are popping the stack\n";
			node* oldtop = top;
			top = top->getNext();
			delete oldtop;
			
		}
};

int main()
{	
	stack s;
	s.push();
	s.push();
	s.push();
	s.pop();

	return 0;
}



