// stack.cpp

#include "stack.h"

Stack::Stack(){ top=0;}		// NULL 

Stack::~Stack()
{ 
		node *q; 
		while( top!=0)
		{
			q=top;
			top=top->next;
			delete q;
		}
		delete top;	
}	

void Stack::push(int x)
{
	node *tmp = new node;
	tmp->key = x;
	tmp->next = top;
	top=tmp;
}

int Stack::pop()
{
	if(isEmpty()) return 0;
	node *ret = top;
	int value = ret->key;
	top = top->next;
	delete ret;
	return value;
}


int Stack::getTop()
{
	return top->key;
}

int Stack::isEmpty()
{
	return (top==0);
}



