#ifndef Stack_H
#define Stack_H

#ifdef GNU
#define std 
#include <iostream.h>
#else
#include <iostream>
#endif

#include "list.h"


////////////////////////////////////////////////////
// CLASS: STACK
// A derived class of List. Stack allows inserts and
// deletes only at the TOP (beginning).
////////////////////////////////////////////////////

template <class EleType>
class Stack: private List<EleType>{
 public:
  //Push element X on TOP of stack
  void Push(const EleType & X);
  void Insert(const EleType & X){ Push(X); }

  //Pop the TOP of the stack and return it
  EleType Pop();

  friend std::ostream & 
    operator << ( std::ostream & out_str, const Stack<EleType> & stk ); 
};

template <class EleType>
void
Stack<EleType>::Push(const EleType & X){
  Head();
  List<EleType>::Insert(X);
}

template <class EleType>
EleType
Stack<EleType>::Pop(){
  First();
  EleType etyp (Current_Value());
  Delete(etyp);
  return etyp;
}

//  Overloaded output operator.  It behaves in the expected way.
//
template <class EleType>
std::ostream &
operator << ( std::ostream & out_str, const Stack<EleType> & stk )
{
  out_str << (List<EleType>) stk;
  return out_str;
}
#endif  


