C++ Keywords

This blog post will teach you about C++ keywords (reserved words in C++ programming). We will list out almost famous C++ keywords and their examples. Let’s first understand what C++ keyword is.

 

Keywords are predefined reserved identifiers that have special meanings. And because they are reserved by the language, these keywords are not available for re-definition or overloading. In simple words, you can not use keywords as identifiers in your program.

For example,

int while;

Here, int and while both are keywords but in the above example, you are trying to use while as an identifier. You will get the compiler error.

C++ Keywords

 

Standard C++ keywords:

The following is the list of keywords used in C++ programming. The meaning of the few keywords is updated in different versions of C++.

A – C D – P R – Z
alignas (since C++11)
alignof (since C++11)
and
and_eq
asm
atomic_cancel (TM TS)
atomic_commit (TM TS)
atomic_noexcept (TM TS)
auto
bitand
bitor
bool
break
case
catch
char
char8_t (since C++20)
char16_t (since C++11)
char32_t (since C++11)
class (1)
compl
concept (since C++20)
const
consteval (since C++20)
constexpr (since C++11)
constinit (since C++20)
const_cast
continue
co_await (since C++20)
co_return (since C++20)
co_yield (since C++20)
decltype (since C++11)
default
delete
do
double
dynamic_cast
else
enum
explicit
export
extern
false
float
for
friend
goto
if
inline
int
long
mutable (1)
namespace
new
noexcept (since C++11)
not
not_eq
nullptr (since C++11)
operator
or
or_eq
private
protected
public
reflexpr (reflection TS)
register
reinterpret_cast
requires (since C++20)
return
short
signed
sizeof
static
static_assert (since C++11)
static_cast
struct
switch
synchronized (TM TS)
template
this
thread_local (since C++11)
throw
true
try
typedef
typeid
typename
union
unsigned
using (1)
virtual
void
volatile
wchar_t
while
xor
xor_eq

 

Note: The register keyword is unused but is reserved for future use.

 

C++ also has some identifiers with special meanings, which may be used as names of objects or functions, but have special meanings in certain contexts. These are the following.

final (C++11)
override (C++11)
transaction_safe (TM TS)
transaction_safe_dynamic (TM TS)
import (C++20)
module (C++20)

 

Recommended Articles for you: