I'm using C++11 and both are compiling without any warning, witch one is the best way to do it?
if(a && b)
or
if(a and b)
Examples: “You should stop eating fast food.” “You should go for walks more often.” “We should go to the park tomorrow.”
Use to + verb is a regular verb and means something that happened but doesn't happen any more. It uses -ed to show past tense. But since it always means something that happened in the past, it should always use past tense. For example- I used to go to school in Paris.
It depends on whether you're making a statement or asking a question. If it's a statement, the format is I should. I should be there by noon. It's just the regular verb format - I should or I can or I will.
Should is used to say that something is the proper or best thing to do, or to say that someone ought to do something or must do something. Adam could visit us on Monday. This tells us that it is possible Adam will visit on Monday, maybe he can visit us, but maybe he has other options, too.
2.6 Alternative tokens [lex.digraph]
1 Alternative token representations are provided for some operators and punctuators.16
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.
Can't paste table 2, but it explicitly states Alternative: and
, Primary &&
(same for or
and ||
).
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.
Edit: The aforementioned Table 2:
Table 2 — Alternative tokens
Alternative Primary
<% {
%> }
<: [
:> ]
%: #
%:%: ##
and &&
bitor |
or ||
xor ˆ
compl ~
bitand &
and_eq &=
or_eq |=
xor_eq ˆ=
not !
not_eq !=
Edit: Maybe worth noting, according to Sebastian Redl, MS break the rules here.
I prefer &&
instead of and
.
&&
is widely known and accepted, while many don't even know that and
is valid C++.and
(and friends) by default. For example MSVC++.&&
and ||
is ingrained into my head. While and
and or
have the same precedences as &&
and ||
, the simple fact that I'm much less used to them makes it harder to read a condition.On the other hand, and
is more verbose and might be easier to use for programmers who have learned programming with languages that don't use &&
. But one could argue that these people should learn C++ rather than try to change it's snytax.
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