How to do it...

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.

  1. 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>
  1. And we do also declare that we are using namespace std in order to spare us some typing.
      using namespace std;
  1. 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 ...

Get Expert C++ Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.