#include <iostream.h>
#include "stack.h"

// Constructor: initialize the stack size to 0
stack::stack()
{
  stack_size = 0;
}

// Accessor function to return the number of items on the stack
int stack::size()
{
  return stack_size;
}

// Push a value onto the stack
void stack::push(int i)
{
  if (stack_size >= MAX_STACK_ITEMS)
    cerr << "stack overflow!\n";
  else
    data[stack_size++] = i;
}

// Pop a value off of the stack
int stack::pop()
{
  if (stack_size <= 0)
    cerr << "stack underflow!\n";
  else
    return data[--stack_size];
}
