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