// Chap 6, pp 260 - 261
// Rename this file as StackA.h
// *********************************************************
// Header file StackA.h for the ADT stack.
// Array-based implementation
// *********************************************************
const int MAX_STACK = 100; // maximum-size-of-stack;
typedef int stackItemType; // desired-type-of-stack-item
#include "boolean.h"
class stackClass
{
public:
// constructors and destructor:
stackClass(); // default constructor
stackClass(const stackClass& S); // copy constructor
~stackClass(); // destructor
// stack operations:
boolean StackIsEmpty();
// Determines whether a stack is empty.
// Precondition: The constructor has been called.
// Postcondition: Returns TRUE if the stack was
// empty, otherwise returns FALSE.
void Push(stackItemType NewItem, boolean& Success);
// Adds an item to the top of a stack.
// Precondition: The constructor has been called. NewItem
// is the item to be added.
// Postcondition: If insertion was successful, NewItem
// is on the top of the stack and Success is TRUE;
// otherwise Success is FALSE.
void Pop(boolean& Success);
// Removes the top of a stack.
// Precondition: The constructor has been called.
// Postcondition: If the stack was not empty, the item
// that was added most recently is removed and Success
// is TRUE. However, if the stack was empty, deletion is
// impossible and Success is FALSE.
void GetStackTop(stackItemType& StackTop,
boolean& Success);
// Retrieves the top of a stack.
// Precondition: The constructor has been called.
// Postcondition: If the stack was not empty, StackTop
// contains the item that was added most recently and
// Success is TRUE. However, if the stack was empty, the
// operation fails, StackTop is unchanged, and Success
// is FALSE. The stack is unchanged.
private:
stackItemType Items[MAX_STACK]; // array of stack items
int Top; // index to top of stack
}; // end class
// End of header file.
               (
geocities.com/siliconvalley/program/2864/ds)                   (
geocities.com/siliconvalley/program/2864)                   (
geocities.com/siliconvalley/program)                   (
geocities.com/siliconvalley)