Meanwhile...
I think the code looks good.
A few minor points.
1. in C++ you should generally initialize at the point of definition rather than define in one statement and then assign to later on. When working with objects this is more important than with built-in types.
2. The coding standards I've worked with require spaces around binary operators (except ->) but not unary ones. (There is an element of personal preference here, but I have not come across a standard mandated "crunched up" code.) And a quick google later I see WebKit, JUCE, and Google agree on this matter.
1 2 3 4
|
double addition (double x, double y) {
double z = x + y;
return z;
}
|
(to be honest I would just code a function like this without a temporary.)
3. using
using namespace std;
is generally a bad idea.
But I do use it when knocking up small utility programs as I'm a bit lazy. And here on the forums it keeps code a bit terser and easier to fit on the web page.
4. the code on lines 50- and 57- looks like it should be factored out into a function.
(This also fits in with handling the numeric inputs using cire's approach, or something similar.)
5. (quibble?) I would have called the functions add, subtract, divide, multiply -- as I like my function names to be verbs (as a general rule.)
Andy
PS I do agree with Gamer2015's suggestion to rework you code to accept input of the form "5 - 3". As a bridging step between your current approach and handling infix notation you could have a go at postfix notation. i.e. accept inputs like "1 2 add" as well as "stop".