C++ Keywords


Keywords are those words whose meaning is already defined by Compiler. These keywords cannot be used as an identifier. Note that keywords are the collection of reserved words and predefined identifiers. Predefined identifiers are identifiers that are defined by the compiler but can be changed in meaning by the user. 

For example, you could declare a variable called main inside your main function, initialize it, and then print out its value (but ONLY do that to verify that you can!). On the other hand, you could not do this with a variable named else. The difference is that else is a reserved word, while main is "only" a predefined identifier.

There are a total of 95 reserved words in C++. 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.

There are another 30 reserved words that were not in C, are therefore new to C++ programming language.

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

Here is a list of all these reserved words:

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

Updated on: 30-Jul-2019

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements