Any downside to using the "and" operator vs the && operator?

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


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.

Tags:

C++

Operators