Hey Zapshe,
Cool job for a start ^_^.
I tried "3 % 5" and had the answer "not applicatble".
This answer is wrong :o) since the result is 3 ;o).
No critics ;o).
I took a look at your code and your main loop is too long.
I suggest you take the habit from now on to call a function anytime you want to do something :o) and even before you code that function. You'll see that your code will tend to be much more readable even if it's still get long.
You can for example, symbolizes your process like this :
1 2 3 4 5 6 7 8
|
for(;;)
{
line = readInput();
command = parse(line);
auto const& result = compute(command);
store(result);
dump();
}
|
This way, you can always complicated thing in each step but your process stays clean :oD~ and very readable.
Also, get rid of the std::cin etc.
Encapsulate all of these calls into functions.
Maybe a time will come, you'll have to change the library you use... code like that is a hell to maintain :o).
No critics ^_^... just some habits you can acquire from now on that will make your code better instantly.
By the way, what was the reason you wrote this code ?
Was it an exercice ?
About calculators, you may want to try a postfix calcultor... because you postfix every operation, the "syntax" become very very easy to parse and you can compute any formula the most simple way possible ^_^.
The postfix style has been also called the reverse polish...
Whay you did is a copy of the way we write the operations as mathematical formula and this way is very difficult to parse compare to the postfix.
But postfix has a "drawback", you must have a stack for the operands :oP
postfix is very funny to try ;o)