I use Bloodshed Dev-C++ version 4.9.9.2 and it is a little weird in that it accepts "and" as "&&" and "or" as "||", not to mention not requiring parentheses around separate clauses in and/or connected statements. Therefore it would read the following as the same.
if(voice==loud or voice==annoying and voice==whiny){
cout<<"SHUT UP!"<<endl;
}
It's not an "abnormality," it's actually part of the C++ standard. As I understand it, operators like 'and' and 'or' are included for users with different character sets. See: http://david.tribble.com/text/cdiffs.htm#C99-alt-tok
Microsoft compilers appear to implement these as macros instead of keywords in the ciso646 header.
As for the second part of your post, the equality operator takes precedence over logical AND, which takes precendence over logical OR, so the parentheses aren't required in either case.
Best stick with && instead of "and" as you'll encounter problems if you switch compilers.
Again, it depends on which country you live in. Not all keyboards have a & key!!!! Actually "and" looks a lot more readable than "&&". Dev-C++ uses a much more international open source GNU compiler. Thank you GloriousEremite for the reference site!
Last edited by vegaseat; Oct 16th, 2006 at 3:04 pm.
I think he does have the & key. So therefore he should use it -if he wants to guarantee better portability.
If not I would expect him to have a little note saying, if you intend to use this code with such and such a compiler please include the relevant header.
>Not all keyboards have a & key!!!!
Can't ya just hold down [alt] + ### or whatever the number is for an ampersand?
Again, it depends on which country you live in. Not all keyboards have a & key!!!! Actually "and" looks a lot more readable than "&&". Dev-C++ uses a much more international open source GNU compiler.
As expected from a Python proponent But seriously, i agree with Mr. Iamthwee, its would be better NOT to use such keywords which are fully integrated in C++ standards but require the inclusion of a seperate header file #include <iso646.h>. So if you want your C++ code to be compatible with C standards, better stick to the && operator.
Quote ...
C90 does not have these built-in keywords, but it does provide a standard header file that contains definitions for the same words as macros, behaving almost like built-in keywords. The recommended practice for code intended to be compiled as both C and C++ is to use "and" identifiers only for special meanings, and only after including the header <iso646.h> .
Last edited by ~s.o.s~; Oct 16th, 2006 at 3:23 pm.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.