What Is a Variable?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/carlhelen/article/details/89029021

A variable is an object that can have a value bound to it dynamically.

That is, the program can change the variable’s value attribute at runtime.

Note the operative word can. It is only necessary for the program to be able to change a variable’s value at runtime; it doesn’t have to bind multiple values in order to consider the object a variable.

Dynamic binding of a value to an object is the defining attribute of a variable, though other attributes may be dynamic or static.

For example, the memory address of a variable can be statically bound to the variable at compile time or dynamically bound at runtime.

Likewise, variables in some languages have dynamic types that change during program execution, while other variables have static types that remain fixed over the execution of a given program.

Only the binding of the value determines whether the object is a variable or something else (such as a constant).

猜你喜欢

转载自blog.csdn.net/carlhelen/article/details/89029021