Any pros/cons to using the "and" operator vs the && operator? I personally think "and" is only going to cause confusion (ironically).
If there aren't any differences, why does it exist? It seems silly and unnecessary.
The difference between AND, OR is that AND evaluates both conditions must be true for the overall condition to be true. The OR evaluates one condition must be true for the overall condition to be true. In the OR result, if name is John then condition will be true.
Remarks. The logical AND operator ( && ) returns true if both operands are true and returns false otherwise. The operands are implicitly converted to type bool before evaluation, and the result is of type bool . Logical AND has left-to-right associativity.
The logical AND ( && ) operator (logical conjunction) for a set of boolean operands will be true if and only if all the operands are true . Otherwise it will be false .
'and' and '&&' is the same operator, apart from precedence differences. They are different operators, but they operate the same, apart from precedence differences. also, using '&&' makes you look cooler.
It's the same operator. The difference is merely one of style. Consult your project documentation, or ask your boss, or your wife, or flip a coin.
They're anachronisms - they were originally introduced to accomodate folks who didn't have "^" or "|" characters on their keyboards.
Furthermore, although "and" and "&&" are equivalent ... "and" and "&" are quite different. Using "and" instead of "&&" is simply confusing on a number of different levels, for several different reasons. Including giving the poor maintenance programmer a completely unnecessary "wtf?" experience.
I would not use them in any code. And I've certainly never seen them used in any "live" code.
IMHO...
Here's a bit more on the topic, if you're interested:
The written versions of the logical operators
http://www.cplusplus.com/reference/ciso646/
https://en.cppreference.com/w/cpp/language/operator_alternative
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With