Submitted Dave Astle, Jul 30 2001 02:01 PM | Last updated Jul 30 2001 02:01 PM
A place in the computer's main memory in which a certain piece of information is stored. Each variable is composed of four parts:
The memory location in which the information is stored
The type of information which will be stored in that location
The information which is stored in that location
An identifier (The name of the variable)
When the programmer declares a variable, he is telling the computer to set aside a certain amount of space in memory. The computer needs to know how much space to set aside, and the programmer gives this information by declaring what type of information will be stored. (Some types of data require more space in memory than others.)
The programmer must also have some way of keeping track of which information is stored in which location. Modern computer games require tremendous amounts of information. Keeping track of the exact memory location of each piece of information would be tedious. So the programmer assigns the variable an identifier. This is the name by which the programmer will refer to the variable.
Suppose a programmer needs to retrieve the hit points of a character named Toadbottom. If the programmer needed to refer to this as "the information stored at 00FF 92CA" it would be a nightmare. But by using an identifier, the programmer could refer to this information as "Toadbottom.hitPoints", or something equally nice.