// ----------------------------------------------------------------
//
// Class : STACK from STACK.H
// Parents :
// Friends :
// Part of :
// Created : 12 Oct 1990 by A.C.Coder
// Abstract : This module implements a dynamic stack for integers.
// Other stacks can be easily constructed by changing
// the defintion of STACK_ITEM type. Note: STACK_ITEM
// should not be any array type.
// Revision : 1.0, 12 Oct 1990 12:00:00, by ACC
//
// Copyright (C) 1990 Sample Software Ltd.
// ----------------------------------------------------------------
// Revision history
//
// 1.0: Initial revision
//
// ----------------------------------------------------------------
#ifndef STACK_H
#define STACK_H
// ------------------------- PUBLIC TYPES -------------------------
//
// STACK_ITEM: The items stored in the stack are of this type
//
typedef int STACK_ITEM;
// ----------------------- CLASS DECLARATION ----------------------
class Stack
{
public:
Stack();
~Stack();
void clear();
unsigned height();
void push(
STACK_ITEM item);
STACK_ITEM pop();
STACK_ITEM top();
protected:
STACK_ITEM &element(unsigned index);
private:
unsigned myheight; // current height of stack
unsigned size; // current size (max. height)
STACK_ITEM *value; // the data in stack
};
// ------------------ INLINE MEMBER DEFINTIONS -------------------
#endif