Please send questions to
st10@humboldt.edu .
//---------------------------------------------------------------------
// File: stack.h
// Name: Sharon M. Tuttle
// last modified: 3-10-05
//
// Class name: stack
//
// Description: a collection of items such that entries can be
// inserted and removed at only one end (called the top).
// This version does NOT have a fixed capacity.
//
//---------------------------------------------------------------------
#ifndef STACK_H
#define STACK_H
#include <cstdlib> // provides NULL
#include "node.h"
using namespace std;
class stack
{
public:
/****************************************************/
/* TYPEDEFS and MEMBER CONSTANTS */
/****************************************************/
typedef double value_type;
/*****************************************************/
/* CONSTRUCTORS and DESTRUCTORS */
/*****************************************************/
// postcondition: creates an empty stack instance
//
stack();
// copy constructor
//
stack(const stack& source);
// destructor
//
~stack( );
/*************************************************************/
/* ACCESSORS and other constant member functions (observers) */
/*************************************************************/
// postcondition: returns true if stack is empty, and
// returns false otherwise
//
bool is_empty( ) const;
// precondition: is_empty() == false
//
// postcondition: returns the value of the top item of the
// stack, BUT the stack is unchanged.
//
value_type get_top( ) const;
// postcondition: returns the number of elements currently
// in the stack
//
int get_size( ) const;
/*****************************************************/
/* MODIFIERS and other modifying member functions */
/*****************************************************/
// postcondition: a new copy of entry has been pushed
// onto the (top of the) stack
//
void push(const value_type& entry);
// precondition: is_empty() == false
//
// postcondition: the top item of the stack has been
// removed, and its value is returned
//
value_type pop( );
private:
/*****************************************************/
/* DATA FIELDS */
/*****************************************************/
node* top; // pointer to node containing top
// of stack
int used; // how many items are in the stack
};
#endif