Stack Based Calculator

This is a stack based calculator that we wrote in the workshop on Tuesday 5/5/98.

For those of you that are interested, there are several more things you can do with this example:

  1. Implement StackCalc's add(), subtract(), multiply(), and divide() methods.
  2. Rewrite StackCalc::evaluate() to be itterative and not recursive.
  3. Modify StackCalc::evaluate() to use '\n' as the end of line character and not ';'. This is pretty tricky.
  4. Add your own new builtin operators. Can you define operators like dup that duplicates the first element on the stack?
  5. Make DoubleStack dynamically grow to allow any size stack.
[back]