





































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






































































#include "ItemType.h" // for MAX_ITEMS and ItemType
template
class StackType
{
public:
StackType( ); bool IsEmpty( ) const; bool IsFull( ) const; void Push( ItemType item ); void Pop( ItemType item ); ItemType Top( );
private:
int top; ItemType items[MAX_ITEMS];
};
[MAX_ITEMS-1] . . .
[MAX_ITEMS-1] . . .
template
StackType
{
top = -1;
}
template
void StackType
{
if (IsFull()) throw FullStack(); top++; items[top] = newItem; // STATIC ARRAY IMPLEMENTATION
}