C++ Keywords and Identifiers


Keywords and Identifiers


Keywords :

  • Keywords are the reserve words which can not be used as variables.
  • These are the sytem defined variables.
  • C++ has many different keywords.
  • White spaces are not allowed in keywords.
  • These are in lower case.
Following table shows the common keywords present in both C and C++.

intfloatdoublelong
shortsignedunsignedconst
ifelseswitchbreak
defaultdowhilefor
registerexternstaticstruct
typedefenumreturnsizeof
gotounionautocase
voidcharcontinuevolatile


Some more standard keywords, which are not used in C language, but mostly in C++ are :




asmcatchconstclass
friendprivatepublicprotected
trythisnewvirtual


And many other...


Identifiers :

  • These are the words or names which identify whether it is a constant, variable or function name in C++.
  • It reprsent unique sequence of characters.
  • These must be maximum upto 31 characters long.
  • All the identifiers are case sensitive.
  • Special characters or keywords should not be used as indentifiers.
Rules in C++ for creating identifiers are :
  • Only alphabet characters, digits and underscores are permitted.
  • The name can't be started with digit.
  • The keyword can't be used as a name.
  • These are case sensitive.
  • Identifier name can't have space.
  • The name can't have a special character.
Example :

Following are some valid identifiers :

number, number1, x, xyz etc.

following are the Invalid identifiers :

7xy(first letter is digit), first name(has space), break(reserve word)



     Prev                                                   NEXT

0 comments:

Post a Comment