///
///
// Stack data structure stack.h //
///
//
#include
Template
Template
Class StackNode
{
Friend Class Stack
Private:
TYPE DATA;
StackNode
StackNode (Type D = 0, StackNode
}
Template
Class Stack
{
PUBLIC:
Stack (): TOP (NULL), NumItem (0) {}
Void Push (Type Item);
TYPE POP ();
TYPE GETTOP ();
Void makeempty ();
Bool isempty ();
Int getnum ();
Private:
Int NumItem;
StackNode
}
Template
Void Stack
{
TOP = New StackNode
Numitem ;
}
Template
TYPE Stack
{
StackNode
TYPE TEMP;
Temp = TOP-> DATA;
P = TOP;
TOP = TOP-> LINK;
Delete P;
Numitem -
Return Temp;
}
Template
TYPE Stack
{
Return Top-> Data;
}
Template
Bool Stack
{
Return Top == NULL;
}
Template
Void Stack
{
DELETE TOP;
}
Template
Int stack
{
Return NumItem;
}