I'm a noob, who is trying to create a simple calculator to practice the whats in the "Basics of C++", but I'm finding it hard to create an operator for ± so I don't have to type (x-y),(x+y). Can you please help me think up any ideas?
± is not a proper mathematical operator, it's an abbreviated way of writing two separate expressions as one. It's only sort of meaningful when writing equations (e.g. x = ±1 means that x is either 1 or -1), it doesn't have a well-defined meaning when expressing a calculation.
For example, if input "1 ± 2 ± 3" into your hypothetical program, which of these do I mean?
* Calculate (1 + 2 + 3) and (1 - 2 - 3).
* Calculate (1 + 2 - 3) and (1 - 2 + 3).
* Calculate all four of the above.
You really don't want such ambiguities in a calculator.
Though I'm struggling to imagine what exactly the function should return if the expression is (x-y),(x+y). If it returns void what use would be such an operator unless you just wish to print to console in which case it would be: