Possible Duplicate:
C++ alternative tokens?
I'm working on an assignment in C++ with a friend of mine, and we've been doing lots of the coding on his computer/environment (a Macbook Pro with Eclipse). In some of the code he has written conditions using and
and or
rather than &&
and ||
. The code compiles just fine on his computer, but when I try and compile it on my computer at home (a PC with Visual Studio 2010) I get compiler errors and am forced to switch them. My friend also attests that this syntax has worked using emacs/g++ in a Linux environment.
I had never seen this type of thing before. Is this used widely or supported by most compilers?
There are a handful of "alternative representations": and , and_eq , bitand , bitor , compl , not , not_eq , or , or_eq , xor , and xor_eq . They are a standard language feature of C++. Visual C++ only supports these as keywords if you compile with the /Za (standards conformance mode) flag. Show activity on this post.
It's much harder to type bitand instead of and than it is to type & instead of && , and frankly I do think it gains in readability.
Difference between “||” and “|” It's the same as above, in the case of “||” only one statement is executed and if it returns “true” then the other statement will not be executed. But if the first is false then the other will be checked for the value “true”. The reason for this is the way the “or” operator works.
There are a handful of "alternative representations": and
, and_eq
, bitand
, bitor
, compl
, not
, not_eq
, or
, or_eq
, xor
, and xor_eq
. They are a standard language feature of C++.
Visual C++ only supports these as keywords if you compile with the /Za
(standards conformance mode) flag.
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