问题描述
我使用的是C ++ 11,两者都是没有任何警告的编译,一个是最好的方法吗?
I'm using C++11 and both are compiling without any warning, witch one is the best way to do it?
if(a && b)
或
if(a and b)
推荐答案
$ b一些运算符和标点符号16
1 Alternative token representations are provided for some operators and punctuators.16
2 在语言的所有方面,每个替代令牌分别表示
2 In all respects of the language, each alternative token behaves the same, respectively, as its primary token, except for its spelling.17 The set of alternative tokens is defined in Table 2.
相同。
如果你想尝试和说服自己一个是比另一个更好,这是你的业务。
So they are absolutely identical.If you want to try and convince yourself one is "better" than the other, that's your business. If someone else is trying to argue such, they'd better have a good reason.
编辑:上面的表2:
Table 2 — Alternative tokens
Alternative Primary
<% {
%> }
<: [
:> ]
%: #
%:%: ##
and &&
bitor |
or ||
xor ˆ
compl ~
bitand &
and_eq &=
or_eq |=
xor_eq ˆ=
not !
not_eq !=
编辑:可能值得注意,根据,MS在这里违反规则。
Maybe worth noting, according to Sebastian Redl, MS break the rules here.
这篇关于我应该使用“&&”或“和”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!