#include"Node.h"
#include"Stack.h"
#include<stdlib.h>

template<class T>
Stack<T>::Stack()
{
    head = NULL;
}

template<class T>
T Stack<T>::pop()
{
   T  x   =   head->get();
   Node<T>*  p   =   head;
   head   =   head->getNext();
   delete  p;
   return  x;
}

template<class T>
void Stack<T>::push (T  x)
{
   
      Node<T>*   newNode   =   new Node<T>();
      newNode->set(x);
      newNode->setNext(head);
      head   =   newNode;
   
}

template<class T>
T Stack<T>::top()
{
   return  head->get();
}

template<class T>
int Stack<T>::isEmpty()
{
   return   ( head   ==   NULL );
}
