Wednesday, 19 March 2014

Reserved words

The syntax rules (or grammar) of C++ define certain symbols to have a unique meaning within a C++ program. These symbols, the reserved words, must not be used for any other purposes. The reserved words already used are int and void. All reserved words are in lower-case letters. The table below lists the reserved words of C++. C++ Reserved Words
andand_eqasmautobitand
bitorboolbreakcasecatch
charclassconstconst_castcontinue
defaultdeletedodoubledynamic_cast
elseenumexplicitexportextern
falsefloatforfriendgoto
ifinlineintlongmutable
namespacenewnotnot_eqoperator
oror_eqprivateprotectedpublic
registerreinterpret_castreturnshortsigned
sizeofstaticstatic_caststructswitch
templatethisthrowtruetry
typedeftypeidtypenameunionunsigned
usingvirtualvoidvolatilewchar_t
whilexorxor_eq
Some of these reserved words may not be treated as reserved by older compilers. However you would do well to avoid their use. Other compilers may add their own reserved words. Typical are those used by Borland compilers for the PC, which add nearfarhugecdecl, and pascal.
Notice that main is not a reserved word. However, this is a fairly technical distinction, and for practical purposes you are advised to treat maincin, and cout as if they were reserved as well.

No comments:

Post a Comment