
	class Node {

	public:
     		Node( T x)                    { val = x; Next = 0; }
     		Node *next()                  { return Next; }
     		void link( Node *neighbor)    { Next = neighbor; }
     		T value()                     { return val; }
	private:
     		Node *Next;
     		T val;
	};

        class Stack {
        public:                 // these members are public
                Stack()                 { head = 0; }
                
                // precondition:  !isfull()
                void push( int x)       
                { 
                	Node *p = new Node( x);
                	if( head == 0)
                		head = p;
                	else {
                		p->link( head);
                		head = p;              	
                	}
                }
                
                // precondition:  !isempty()
                int pop()               
                { 
                	int r = head->value();
                	Node *p = head;
                	head = head->next();
                	delete p;
                	return r; 
                }
                
                Truth isempty()         { return head == 0; }
               
                Truth isfull() 
                {
                	Node *p = new Node( 0);
                	delete p;
                	return (p == 0);
                }
        private:                // these (data) members are private
                Node *head;
        };

