Listing 2: Using the Interpreter pattern for evaluating (x+2)*3

void someFunction(double x)
{
  Product expr(new Sum(new Variable(x),
new Literal(2)),
new Literal(3)); cout << expr.eval() << endl; } — End of Listing —