keywords
suggest changeKeywords have fixed meaning defined by the C++ standard and cannot be used as identifiers. No translation unit may #define or #undef a name that is lexically identical to a keyword. Inside an attribute-token, a keyword is treated as an identifier.
Remarks
Through C++17, the keywords are:
alignas(since C++11)alignof(since C++11)asmauto: since C++11, before C++11boolbreakcasecatchcharchar16_t(since C++11)char32_t(since C++11)classconstconstexpr(since C++11)const_castcontinuedecltype(since C++11)defaultdeletefor memory management, for functions (since C++11)dodoubledynamic_castelseenumexplicitexportexternas declaration specifier, in linkage specification, for templatesfalsefloatforfriendgotoifinlinefor functions, for namespaces (since C++11), for variables (since C++17)intlongmutablenamespacenewnoexcept(since C++11)nullptr(since C++11)operatorprivateprotectedpublicregisterreinterpret_castreturnshortsignedsizeofstaticstatic_assert(since C++11)static_caststructswitchtemplatethisthread_local(since C++11)throwtruetrytypedeftypeidtypenameunionunsignedusingto redeclare a name, to alias a namespace, to alias a typevirtualfor functions, for base classesvoidvolatilewchar_twhile
C++20 also adds char8_t, concept, consteval, constinit, co_await, co_return, co_yield, and requires.
The tokens final, override, import, and module are not keywords. They may be used as identifiers and have special meaning only in certain contexts.
The tokens and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, and xor_eq are keywords. They are alternative spellings of &&, &=, &, |, ~, !, !=, ||, |=, ^, and ^=, respectively.
The following topics contain detailed explanations of many of the keywords in C++, which serve fundamental purposes such as naming basic types or controlling the flow of execution.
- Basic Type Keywords
- Flow Control
- Iteration
- Literal Keywords
- Type Keywords
- Variable Declaration Keywords
- Classes/Structures
- Storage class specifiers
Querying the alignment of a type