C++ Keywords and Identifiers

Keywords

A keywords are the reserved words in programming language with a specific features for each keyword. Keywords always starts with the lower case and cannot be a variable name or constant name. These are predefined by the program and their value cannot be changed.

Example: int, float, public, etc.

The following is the list of 30 keywords in C++ that are also available in C programming language.

autobreakcasecharconst
doubleelseenumexternfloat
intlongregisterreturnshort
structswitchtypedefunionunsigned
continuedefaultdoforgoto
ifsignedsizeofstaticvoid
volatilewhile

The following is the list of 30 keywords in C++ that are not available in C programming language.

asmdynamic_castnamespacereinterpret_castbool
explicitnewstatic_castfalsecatch
operatortemplatefriendprivateclass
thisinlinepublicthrowconst_cast
deletemutableprotectedtruetry
typeidtypenameusingvirtualwchar_t

Identifiers

Identifiers are nothing but the name assigned to the entities such as variables, functions, arrays, or other user-defined data types. Identifiers are the basics need of programming language.

The name assigned to the entities is unique so that it can be identified during the execution of the program. Identifiers cannot be used as Keywords.

Example: int number;, number being an identifier.

Rules for naming identifiers:

  • Identifiers are case-sensitive that is uppercase and lowercase letters are distinct.
  • The first letter of identifiers must be a letter or underscore. After the first letter, you can use digits.
  • White spaces are not allowed.
  • A keyword cannot be used as an identifier.

Some valid and invalid identifiers:

//Valid
Number  
result1  
_multiply  
S2C

//Invalid
Number-2   //special character '-' is present.  
3Sum    //started with digit   
int    // int is a keyword