C++ Keyword?

Started by
12 comments, last by daviangel 15 years, 9 months ago
Did the words "and" and "or" become C++ keywords, or is it just Code::Blocks that is saying that they are?
------------George Gough
Advertisement
IIRC, they are optional keywords that quite a few compilers support. They are in the standard, but aren't required to be supported.
All compilers are required to support them. It's the same in C, but you must include iso646.h to get them.
VC++2008 doesn't seem to support them without #include <ciso646>. In C++ I think they're meant to 'just work' without any headers, but whatever. [rolleyes]
Do they do the same thing as && and ||?
------------George Gough
More to the point, if they work the same why not just use && and ||? Less typing!

Visit http://www.mugsgames.com

Stroids, a retro style mini-game for Windows PC. http://barryskellern.itch.io/stroids

Mugs Games on Twitter: [twitter]MugsGames[/twitter] and Facebook: www.facebook.com/mugsgames

Me on Twitter [twitter]BarrySkellern[/twitter]

Quote:Original post by PKLoki
More to the point, if they work the same why not just use && and ||? Less typing!


Another mystery solved:

Quote:
[iso646.h] defines a number of macros which allow programmers to use C language bitwise and logical operators, which, without the header file, cannot be quickly or easily typed on some international and non-QWERTY keyboards.


It simply was not possible to type thoes symbols on some keyboards :)

Simiarly trigraphs were introduced to solve the same problem (albeit for different characters).

Quote:
The reason for their existence is that the basic character set of C (a subset of the ASCII character set) includes nine characters which lie outside the ISO 646 invariant character set. This can pose a problem for writing source code if the keyboard being used does not support any of these nine characters. The ANSI C committee invented trigraphs as a way of entering source code using keyboards that supported any version of the ISO 646 character set. Non-ASCII ISO 646 character sets are not much used today, but trigraphs remain in the C99 standard[


[Edited by - fpsgamer on July 20, 2008 8:29:42 PM]
Makes sense!

Visit http://www.mugsgames.com

Stroids, a retro style mini-game for Windows PC. http://barryskellern.itch.io/stroids

Mugs Games on Twitter: [twitter]MugsGames[/twitter] and Facebook: www.facebook.com/mugsgames

Me on Twitter [twitter]BarrySkellern[/twitter]

Or you could use them to save the person reading the code the mental effort of translating the symbol into the English word. And seriously - that's a savings of one character for '&&' vs 'and', and zero for '||' vs 'or'. Big whoop.
Quote:Original post by Zahlman
Or you could use them to save the person reading the code the mental effort of translating the symbol into the English word. And seriously - that's a savings of one character for '&&' vs 'and', and zero for '||' vs 'or'. Big whoop.


Actually if you count having to hit the shift key (on American keyboards at least), && is the same at three strokes and || is more typing than or.

This topic is closed to new replies.

Advertisement