Jump to content
  • Advertisement
Sign in to follow this  
KodeNerd

C++ Keyword?

This topic is 3713 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Did the words "and" and "or" become C++ keywords, or is it just Code::Blocks that is saying that they are?

Share this post


Link to post
Share on other sites
Advertisement
IIRC, they are optional keywords that quite a few compilers support. They are in the standard, but aren't required to be supported.

Share this post


Link to post
Share on other sites
All compilers are required to support them. It's the same in C, but you must include iso646.h to get them.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!