What is reserve words or keywords in C++

Keywords in C++ are reserve words of any programming language which have a predefined meaning to the compiler. As like as other programming language C++ also have some reserve words which is called keywords in C++. In this article we will see all the keywords in C++.

However, we can not use keywords as the variable name or other name inside our program. They have a specific meaning in the program. If we  use keywords as the name of a variable then we will get an error.

If you have some basic knowledge about C language, then you may have learn some keywords for C there. As we know, all C code is valid for C++ (except a few), so most of the C keywords are also keywords for C++. At first let’s see the common keywords which is existed both in C and C++.

List of common keywords in C++ and C

Common keywords in C++ and C
auto
double
int
struct
break
else
long
switch
case
enum
register
typedef
unsigned
short
float
const
goto
default
sizeof
volatile
while
if
static
do
continue
for
signed
void
union
return
extern
char
break

C++ keywords which are not available in C

C++ keywords list
bool
catch
class
const_cast
try
wchar_t
reinterpret_cast
private
false
true
through
virtual
friend
static_cast
namespace
public
using
protected
new
dynamic_cast
template
mutable
typename
inline
asm
operator
explicit
delete
this
typeid

Using keywords as variable name or function name is not valid. We will get error if we use any keyword as function name or variable name.

float inline = 3.592    // error! inline is a keyword
int extern = 40;    // error! extern is a keyword
char this = 'h';    // error!

Previous pageConstant and literals in C++

Next pageC++ storage classes