// StackType.cpp in StackType2/
//same as first stack class except for the template stuff

//note no include of StackType.h because this file is included in it.

using namespace std;

//note no difference in the functions' code

//this is the templated StackType class.  The template parameter is 
//called ItemType because it serves similar purpose as our old ItemType
//class (or typedef).

//These are the member functions of the templated StackType class, thus
//all the < > stuff.

template<class ItemType>
StackType<ItemType>::StackType()
{
    top = -1;
}

template<class ItemType>
void StackType<ItemType>::MakeEmpty()
{
    top = -1;
}

template<class ItemType>
bool StackType<ItemType>::IsEmpty() const
{
    return (top == -1);
}

template<class ItemType>
bool StackType<ItemType>::IsFull() const
{
    return (top == MAX_ITEMS - 1);
}

template<class ItemType>
void StackType<ItemType>::Push(ItemType newItem)
{
    top++;
    items[top] = newItem;
}

template<class ItemType>
void StackType<ItemType>::Pop(ItemType& item)
{
    item = items[top];
    top--;
}



