The difference between "or" and "||"

Is there any difference between

if ( a or b or c ) {

... and ...

if ( a || b || c ) {

... and more common between the two operators, even in terms of priority?

+5
source share
4 answers

Besides the stylistic meaning that makes many experienced programmers think: β€œYes, did someone suddenly start writing Pascal?” There is no functional difference.

The purpose of these alternative names is to allow people living, say, in Sweden or Germany, to use the standard local version of ASCII, where |- ΓΆ.

Unicode ASCII , "" "" .

+6

operator or.

.

C ++.

operator or , operator|| , .

:

> prog.cpp: In function β€˜bool operator||(Type, Type)’:
> prog.cpp:8:6: error: redefinition of β€˜bool operator||(Type, Type)’
> prog.cpp:4:6: error: β€˜bool operator||(Type, Type)’ previously defined here

ideaone:

class Type {}
};

bool operator or(Type lhs, Type rhs) {
    return true;
}

bool operator ||(Type lhs, Type rhs) {
    return false;
}

int main() {
    Type a;
    Type b;
    a or b;
    a || b;
}
+2

ISO14882: 2011 (e) 2.6-2 ( 2) or || , , :

, , .

#define or || .

and, bitor, xor, compl, bitand, and_eq, or_eq, xor_eq, not not_eq.

+1

, , , . : MSVC, ++ Builder , , or . or .

+1

All Articles