Friday, July 11, 2008

2. Variables, Types and Expressions


2.1 Identifiers

As we have seen, C++ programs can be written using many English words. It is useful to think of words found in a program as being one of three types:
Reserved Words. These are words such as if, int and else, which have a predefined meaning that cannot be changed. Here's a more complete list: 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
using namespace bool static_cast const_cast dynamic_cast

true false
Click
here to group these words into categories.
Library Identifiers. These words are supplied default meanings by the programming environment, and should only have their meanings changed if the programmer has strong reasons for doing so. Examples are cin, cout and sqrt (square root).
Programmer-supplied Identifiers. These words are "created" by the programmer, and are typically variable names, such as year_now and another_age.
An identifier cannot be any sequence of symbols. A valid identifier must start with a letter of the alphabet or an underscore ("_") and must consist only of letters, digits, and underscores.

0 comments: