Home Segments Index Top Previous Next

39: Mainline

A C++ identifier is a name consisting of letters and digits, the first of which must be a letter, with underscore, _, counting as a letter.

A variable is an identifier that serves as the name of a chunk of computer memory. Thus, each variable refers to a chunk of memory.

The variable's data type determines the size of the chunk and the way the bits in the chunk are interpreted. If the variable belongs to the int data type, a kind of integer, the chunk of memory involved is likely to contain 32 bits, one of which determines the integer's sign and 31 of which determine the integer's absolute value.

The chunk of memory named by a variable is said to hold that variable's value. As a program runs, a variable's value may change, but a variable's data type never changes. Thus, the value of an integer variable named length could be the integer 40 at one time and the integer 41 at another, but length's value could never be a floating-point number, such as 40.5.