// lifo.cpp  -- Stack of characters (dynamic storage)

#include "lifo.h"

#define NULL 0


// Create and initialize a lifo
// It returns a lifo whose next field is null and 
// whose count is 0
Lifo::Lifo()
{
	next  = NULL;
}


// push a new value into an existing lifo
void Lifo::push(char who)
{
	node *a = new node;

	a->next = next;
	a->value = who;
	next = a;
}

// pop a value from a lifo
char Lifo::pop()
{
	node *headNode;
	char who;

	if (next != NULL) {
		headNode = next;
		next = next->next;
		who = headNode->value;
		delete headNode;
		return who;
	}
	return '\0'; // You should never execute this
	          // statement (i.e. do not pop
			  // an empty stack)
}

// check if a lifo is empty
int Lifo::isempty()
{
	return (next == NULL);
}
