Key Words in C++ (C++20)
The following list displays the keywords (or reserved words), which cannot be used for any other purpose in the source code, such as variable names.
Each keyword has a specific meaning and purpose in the C++ language.
- asm – Insert assembly language code
- auto – Automatic type deduction for variables
- bool – Boolean data type (true/false)
- break – Exit from loops or switch statements
- case – Label in a switch statement
- catch – Handle exceptions in try-catch blocks
- char – Character data type
- class – Define a class
- const – Declare constants
- const_cast – Cast away constness
- continue – Skip to next iteration in a loop
- default – Default case in a switch statement
- delete – Deallocate memory allocated with new
- do – Start a do-while loop
- double – Double-precision floating point number
- dynamic_cast – Safely cast pointers or references in inheritance hierarchies
- else – Alternate branch in if-else
- enum – Declare an enumerated type
- explicit – Prevent implicit conversions for constructors
- extern – Declare variables defined elsewhere
- false – Boolean false value
- float – Floating point number
- for – Looping construct
- friend – Grant access to private/protected members of a class
- goto – Jump to a labeled statement
- if – Conditional statement
- inline – Suggest inline expansion for a function
- int – Integer data type
- long – Long integer data type
- mutable – Allow modification of member even in const object
- namespace – Define a namespace
- new – Allocate memory dynamically
- operator – Overload an operator
- private – Private access specifier
- protected – Protected access specifier
- public – Public access specifier
- register – Suggest storing variable in a CPU register
- reinterpret_cast – Low-level pointer/reference cast
- return – Return a value from a function
- short – Short integer data type
- signed – Signed integer type
- sizeof – Get size of a type or variable
- static – Static storage duration or class member
- static_cast – Compile-time cast
- struct – Define a structure
- switch – Multi-way conditional statement
- template – Define template for generic programming
- this – Pointer to current object
- throw – Throw an exception
- true – Boolean true value
- try – Define a block to catch exceptions
- typedef – Create type aliases
- typeid – Obtain type information
- typename – Specify type name in templates
- union – Define a union
- unsigned – Unsigned integer type
- using – Introduce namespace or type alias
- virtual – Declare virtual functions for polymorphism
- void – Function returns nothing
- volatile – Variable may be modified externally (e.g., hardware)
- wchar_t – Wide character type
- while – Looping construct
- alignas – Specify alignment requirement
- alignof – Get alignment of a type
- char16_t – 16-bit character type
- char32_t – 32-bit character type
- concept – Define template concept
- consteval – Evaluate at compile time
- constexpr – Constant expression
- constinit – Initialize constant at compile time
- co_await, co_return, co_yield – Coroutine keywords
- decltype – Get type of expression
- noexcept – Declare function does not throw exceptions
- nullptr – Null pointer constant
- static_assert – Compile-time assertion
- thread_local – Declare thread-local variable