Keywords in C++

There are some reserved words in C++ that we cannot use as identifiers. These words have special meaning and perform a predetermined task. We call them keywords in C++.

Keywords in C++

There are 32 keywords in C++, that are also present in C programming Language. These 32 keywords have been listed here.


auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while


You may read: Break and Continue in C++

Reserved words in C++

Besides these 32 keywords, there are another 30 reserved words in C++ that are not present in C. These keywords are given below.


asm dynamic_cast namespace reinterpret_cast try
bool explicit new static_cast typeid
catch false operator template typename
class friend private this using
const_cast inline public throw virtual
delete mutable protected true wchar_t

There are 11 more keywords that are not essential when we are using standard ASCII character set but they provide more readable alternatives for some of the C++ operators. They are also used to facilitate programming with character sets that lack characters needed by C++. These 11 reserved words have been listed here.


and compl or_eq
and_eq not xor
bitand not_eq xor_eq
bitor or

As we have discussed earlier, we cannot use these keywords for identifiers i.e. variables names, function names. If we do so, the compiler will throw an error.

See the code here.

#include <iostream>

int main()
  //while is a reserved keyword
  //using while as a variable
  int while=9; 
  //trying to print  value stored in while variable
  return 0;
  //the compiler will throw an error



Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *