IDENTIFIERS AND KEYWORDS
Identifiers can be defined as the name of the variables and
some other program elements using the
combination of the following characters.
Alphabets :
a . . . z, A . . . Z
Numerals :
0 . . . 9
Underscore : _
Special characters All
characters other then listed as alphabets, numerals and underscore, are treated
as special characters. For example, [ ]
, blank space,( ) etc.
In C++ language,
upper case and lower case letters are distinct and hence there are 52 letters
in all. A variable should not begin with a digit. C++ does not set a maximum
length for an identifier. For some compilers, only the first ‘n’ characters of an identifier
are treated as significant, where n
is some fixed value defined in the reference manual of the compiler.
Some examples of valid identifiers are as follows:
My_name
i
I
h_Love
Note that second and third identifiers i
and I
are distinct
and that the underscore_ character is counted as a letter. Some example
of invalid identifiers are :
3ab - variable begins with a digit - inadmissible
A () test -
use of special characters - inadmissible
Gross salary
-
space between characters of a single variable - inadmissible
Keywords The keywords are also identifiers but cannot be user
defined since they are reserved words. The following words are reserved for use
as keywords. We should not choose them as variables or identifiers. It is
mandatory that all the keywords. We should be in lower case letters.
asm continue float
new signed try
auto default for operator sizeof typedef
break delete friend
private static union
case do goto
protected struct unsigned
catch double if public switch virtual
char else inline
register template void
class enum int
return this volatile
const extern long short throw while
No comments:
Post a Comment