Your problem is probably that you haven't got #include <string>
in the beginning of your code.
The order of evaulation of &&
and ||
expressions is strictly "left to right", and guaranteed to "short circuit" when the expression is determined by the left operand.
When using other operators, it is undefined, so for example if (changeString1(word) + changeString2(word))
, the compiler would be allowed to call changeString2
before changeString1
.
In other words, when there is an &&
(and) in the expression, if the first condition is false, the second expression is not evaluated, and if the first expression is true, the second is evaluated. Since both are indeed true in this case, both are evaluated.