In this section, we will read a mathematical expression in RPN from the standard input, and then feed it into a function that evaluates it. In the end, we print the numeric result back to the user.
- We will use a lot of helpers from the STL, so there are a few includes:
#include <iostream> #include <stack> #include <iterator> #include <map> #include <sstream> #include <cassert> #include <vector> #include <stdexcept> #include <cmath>
- And we do also declare that we are using namespace std in order to spare us some typing.
using namespace std;
- Then, we immediately start implementing our RPN parser. It will accept an iterator pair, which denotes the beginning and end of a mathematical expression in string form, which will ...