The text for this exercise reads:
Modify the desk calculator so
that it can be invoked from main() or other functions as a simple
function call.
This is actually very easy. Use the calculator code from 6.1.7
double evaluate(const char* expression)
{
istrstream a(expression);
input = &a;
return expr(true);
}
double evaluate(string str)
{
return evaluate(str.c_str());
}
Simple isn't it?.
Back to the Exercise Page
Back to my Home Page