C++ Keywords

This is a list of reserved keywords in C++. Since they are used by the language, these keywords are not available for re-definition (or overloading) by programmers.

KeywordDescription
andalternative to && operator
and_eqalternative to &= operator
asminsert an assembly instruction
auto(C++0x) automatically detect variable type from initializer expression (meaningless declare a local variable in pre-C++0x)
bitandalternative to bitwise & operator
bitoralternative to | operator
boolname of builtin boolean type
breakbreak out of a loop
casein switch statement, defines a value label
catchhandles exceptions from throw
charname of builtin character type (also 8-bit integer type)
classdeclare a class
complalternative to ~ operator
constmodifier for a variable, a pointer to, or a reference to, which states that the variable cannot be modified
const_castcast that only allows to strip 'const' or 'volatile' modifiers
continuebypass iterations of a loop
defaultdefault handler in a case statement (in C++0x also force default implementation of a method)
deletemake dynamic memory available (in C++0x also remove a method that would be provided by default otherwise)
dobegin of a 'do-while' looping construct
doublename of a builtin double precision floating-point type
dynamic_castcast a pointer/reference from base (polymorphic) class to derived class, with runtime error reporting, if cast is not correct
elsealternate case for an if statement
enumdeclare an enumeration type
explicitmake a class's one-argument constructor not allowed to be used for implicit conversions
exportstates that the following template declaration will be defined in another compilation unit
externdeclares an external linkage for a variable (if not initialized, provides only forwarding declaration for a variable to be declared either later or in another compilation unit) or (extern ā€œCā€) declares C linkage for a function
falsea constant representing the boolean false value
floatname of a single precision floating-point type
forlooping construct
friendgrant non-member function access to private data
gotojump to a label (within the same function)
ifexecute code based on the result of a test
inlinedeclare that a function is to be expanded in place when called (or to undergo vague linkage, if expanding is not possible)
intname of a builtin default integer type
longname of a builtin long integer variable
mutablewipe constness from a class's field, when whole object is const
namespacepartition the global namespace by defining a scope
newcreate an object, allocating memory from dynamic pool
notalternative to ! operator
not_eqalternative to != operator
operatorcreate overloaded operator functions
oralternative to || operator
or_eqalternative to |= operator
privatedeclare private members of a class
protecteddeclare protected members of a class
publicdeclare public members of a class
registerrequest that a variable be implemented by machine's register rather than on function's stack
reinterpret_castcast between any pointers or any integer with no change, which does not strip const or volatile modifiers
returnreturn from a function
shortdeclare a short integer variable
signedmodify variable type declarations
sizeofreturn the size of a variable or type
staticcreate permanent storage for a variable
static_castcast that can be done implicitly in reverse, with changing the pointer for derived class, if required
structdefine a new structure
switchexecute code based on different possible values for a variable
templatecreate generic functions or classes
thisa pointer to the current object inside a class's method
throwthrows an exception
truea constant representing the boolean true value
tryexecute code that can throw an exception
typedefcreate a new type name from an existing type
typeiddescribes an object
typenamedeclare that the identifier next to this word must be always interpreted as type (and not a variable or function), also declares type parameter for template
uniona structure that assigns multiple variables to the same memory location
unsignedmodifier for integer types that makes them only positive range
usingimport complete or partial namespaces into the current scope
virtualcreate a function that can be overridden by a derived class
voidname of a builtin void type or declare no return value in function
volatilewarn the compiler about variables that can be modified unexpectedly
wchar_tname of a builtin wide-character type
whilebegin of 'while' or end of 'do-while' looping constructs
xoralternative to ^ operator
xor_eqalternative to ^= operator