C++ and,or,not,xor 关键字

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2393673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 23:18:35  来源:igfitidea点击:

C++ and,or,not,xor keywords

c++operators

提问by uray

Possible Duplicate:
The written versions of the logical operators.

可能的重复:
逻辑运算符的书面版本。

I notice that C++ define keyword and, or, not, xor, and_eq, or_eq, not_eqand xor_eqas an alternative to &&, ||, !, ^, &=, |=, !=and |=. and they're rarely used! What's wrong? Are they not portable?

我注意到,c + +定义关键字andornotxorand_eqor_eqnot_eqxor_eq作为替代&&||!^&=|=!=|=。他们很少使用!怎么了?它们不便携吗?

采纳答案by Maciej Piechotka

They come from C AFAIR from times when it was not known what special symbols are on the keyboard. So to have portable language they were defined so anyone can use C even if (s)he used keyboard with no &, |or ^(etc.).

它们来自 C AFAIR,当时不知道键盘上有什么特殊符号。因此,为了拥有可移植的语言,它们被定义为任何人都可以使用 C,即使(她)使用没有&,|^(等)的键盘。

Nowadays when QWERTY is a standard (with AZWERTY & co. as variations) it is no longer an issue.

如今,当 QWERTY 成为标准(以 AZWERTY & co. 作为变体)时,它不再是问题。

PS. And of course for obfuscation code competitions ;)

附注。当然还有混淆代码竞赛;)