A valid
identifier is a sequence of one or more letters, digits or underline symbols ( _ ). The length of an
identifier is not limited, although for some compilers only the 32 first
characters of an identifier are significant.
Neither
spaces nor marked letters can be part of an identifier. Only letters, digits
and underline characters are valid. In addition, variable identifiers should
always begin with a letter. They can also begin with an underline character ( _ ), but this is usually
reserved for external links. In no case they can begin with a digit.
Another
rule that you have to consider when inventing your own identifiers is
that they cannot match any key word of the C++ language nor your
compiler's specific ones since they could be confused with these. For example,
the following expressions are always considered key words according to the
ANSI-C++ standard and therefore they must not be used as identifiers:
asm, auto, bool, break, case, catch,
char, class, const, const_cast, continue, default, delete, do, double,
dynamic_cast, else, enum, explicit, extern, false, float, for, friend, goto,
if, inline, int, long, mutable, namespace, new, operator, private, protected,
public, register, reinterpret_cast, return, short, signed, sizeof, static,
static_cast, struct, switch, template, this, throw, true, try, typedef, typeid,
typename, union, unsigned, using, virtual, void, volatile, wchar_t
Additionally,
alternative representations for some operators do not have to be used as
identifiers since they are reserved words under some circumstances:
and, and_eq, bitand, bitor, compl, not,
not_eq, or, or_eq, xor, xor_eq
Your compiler
may also include some more specific reserved keywords. For example, many
compilers which generate 16 bit code (like some compilers for DOS) also include
far, huge
and near as
key words.
The
C++ language is "case sensitive", that means that an identifier
written in capital letters is not equivalent to another one with the same name
but written in small letters. Thus, for example the variable RESULT is not the same
as the variable result
nor the variable Result.
No comments:
Post a Comment