Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Operators in C and C++
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Synonyms === C++ defines keywords to act as aliases for a number of operators:<ref name="Committee">{{cite book | title = ISO/IEC 14882:1998(E) Programming Language C++ | date = 1 September 1998 | publisher = open-std.org β The C++ Standards Committee | pages = 40β41}}</ref> {| class="wikitable" style="width:30%; text-align:center;" ! Keyword || Operator |- | {{code|and}} || <code>&&</code> |- | {{code|and_eq}} || <code>&=</code> |- | {{code|bitand}} || <code>&</code> |- | {{code|bitor}} || <code>|</code> |- | {{code|compl}} || <code>~</code> |- | {{code|not}} || <code>!</code> |- | {{code|not_eq}} || <code>!=</code> |- | {{code|or}} || <code>||</code> |- | {{code|or_eq}} || <code>|=</code> |- | {{code|xor}} || <code>^</code> |- | {{code|xor_eq}} || <code>^=</code> |} Each keyword is a different way to specify an operator and as such can be used instead of the corresponding symbolic variation. For example, {{code|1=(a > 0 and not flag)}} and {{code|1=(a > 0 && !flag)}} specify the same behavior. As another example, the <code>bitand</code> keyword may be used to replace not only the ''bitwise-and'' operator but also the ''address-of'' operator, and it can be used to specify reference types (e.g., {{code|1=int bitand ref = n}}). The ISO C specification makes allowance for these keywords as preprocessor macros in the header file [[iso646.h|{{code|iso646.h}}]]. For compatibility with C, C++ also provides the header {{code|iso646.h}}, the inclusion of which has no effect. Until C++20, it also provided the corresponding header [[ciso646|{{code|ciso646}}]] which had no effect as well.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)