Exploring C++ 11: Problems and Solutions Handbook

Project 4, Exploration 71: Calculator

The calculator project is the most complicated one, being the last. I recommend following the six steps I outline in Exploration 71. The files below show the evolution of my solution as I follow the six steps. The parser undergoes the greatest change, although its central spirit remains the same throughout all steps.

In this project, I use Boost.Test for the unit-testing framework. The project was just too complicated for the trivial test.hpp file that other projects use. If you do not have access to Boost for any reason, do not compile the tester program, only the calc program.

See also the main projects page.

  1. Simple parser, arithmetic expressions
  2. Add variables and assignment
  3. Store and evaluate parse trees
  4. Define simple functions
  5. Save and load libraries
  6. Support additional data types