This page contains a list of all the reserved words in Standard C++, and a few predefined identifiers for the sake of comparison.

Recall the distinction betweenreserved wordsandpredefined identifiers, which are collectively referred to (by us, at least) askeywords. But be aware that this terminology is not standard. For example, some authors will usekeywordin the same sense that we have usedreserved word.

The reserved words of C++ may be conveniently placed into several groups. In the first group we put those that were also present in the C programming language and have been carried over into C++. There are 32 of these, and here they are:

auto const double float int short struct unsigned

break continue else for long signed switch void

case default enum goto register sizeof typedef volatile

char do extern if return static union while

There are another 30 reserved words that were not in C, are therefore new to C++, and here they are:

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

The following 11 C++ reserved words are not essential when the standard ASCII character set is being used, but they have been added to provide more readable alternatives for some of the C++ operators, and also to facilitate programming with character sets that lack characters needed by C++.

and bitand compl not_eq or_eq xor_eq

and_eq bitor not or xor

Note that your particular compiler may not be completely up-to-date, which means that some (and possibly many) of the reserved words in the preceding two groups may not yet be implemented.

Beginning C++ programmers are sometimes confused by the difference between the two termsreserved wordandpredefined identifier, and certainly there is some potential for confusion.

One of the difficulties is that some keywords that one might "expect" to be reserved words just are not. The keywordmainis a prime example, and others include things like theendlmanipulator and other keywords from the vast collection of C++ libraries.

For example, you could declare a variable calledmaininside yourmainfunction, initialize it, and then print out its value (but you probably shouldn't, except as an experiment to verify that you can!). On the other hand, you couldnotdo this with a variable namedelse. The difference is thatelseis areserved word, whilemainis "only" apredefined identifier.

Here is a very short list of some of the predefined identifiers you may have encountered:

cin endl INT_MIN iomanip main npos std

cout include INT_MAX iostream MAX_RAND NULL string

Reference: