3.5. Evaluating a Product

double product (NodePtr& input)
{
  double result = term(input);
  while (input != 0 &&
         (input->data == "*" || input->data == "/"))
    {
      string op = input->data;
      input = input->next;
      assert (input != 0);
      double value = term(input);
      if (op == "*")
        result *= value;
      else
        result /= value;
    }
  return result;
}

In the Forum:

(no threads at this time)