Sie sind auf Seite 1von 4

Keywords and Reserved Words :

Keywords are predefined identifiers, that are used in the syntax


and can be used as identifiers again.
Reserved words are the words in a programming language
which has a fixed meaning and cannot be redefined by the programmer.
They cannot be used as identifers(variables, functions etc).
All reserved words and keywords are in lowercase letters.
But be aware that this terminology is not standard. For example, In

some books it was mentioned that Reserved words are also called as
Reserved Keywords and some authors will use keyword in the same
sense that we have used Reserved word.
Infact all keywords are subset of Reserve words.
Keywords can be redefined while Reserved words cannot be
redefined and used.
Forexample:
#include<iostream>
using namespace std;
int main()

// here main is the keyword

{
int main;

// it can be redefined

For Reference : http://comsciguide.blogspot.com/

main = 1;
cout<< main;
return 0;
}

Here main is the keyword. So it can be redefined and used as an


identifier.
Output:
1

#include <iostream>
using namespace std;
int main()
{
int auto;
auto = 1;
cout<< auto;
return 0;
}

Here auto is an Reserved word. It cannot be redefined. So it


gives an error.
In general reserved words and keywords need not coincide, but
in most modern programming languages, keywords are a subset of
reserved words, as this makes parsing easier, since keywords cannot be
For Reference : http://comsciguide.blogspot.com/

confused with identifiers. In some languages, like C or Python, reserved


words and keywords coincide, while in other languages, like Java, all
keywords are reserved words, but some reserved words are not keywords
these are "reserved for future use".

HereisalistofReservedwordsandkeywords.
C++ Rerserved words :
The reserved words of C++ may be conveniently placed into 3
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, and here they are:
auto

const

double

float

int

short

struct

unsigned

break

continue

else

for

long

signed

switch

void

case

default

enum

goto

register

sizeof

typedef

volatile

char

do

extern

if

return

static

union

while

There are another 30 reserved words that were not in C, are


therefore new to C++, and here they are:
asm

dynamic_cast

bool

explicit

namespace

reinterpret_cast

For Reference : http://comsciguide.blogspot.com/

try

export

new

static_cast

typeid

catch

false

operator

template

using

class

friend

private

this

typename

const_cast inline

public

throw

virtual

delete

protected

true

wchar_t

mutable

The following 11 C++ reserved words have been added to


provide more readable alternatives for some of the C++ operators, but
they are not essential when the standard ASCII character set is being used.

and

bitand

compl

not_eq

or_eq

and_eq

bitor

not

or

xor

xor_eq

Predefined Identifiers :
Here is a very short list of some of the predefined identifiers :
cin
cout

endl
include

INT_MIN
INT_MAX

iomanip main
iostream MAX_RAND

For Reference : http://comsciguide.blogspot.com/

npos
NULL

std
string

Das könnte Ihnen auch gefallen