140: Highlights
- A local variable is a variable that is declared inside a
function definition. A global variable is a variable that is
defined outside of any function definition.
- C++ isolates parameters and local variables, enabling you to
reuse their names. Accordingly, the values of a function's
parameters and local variables are not available after that
function has returned. Also, when one function calls another, the
values of the parameters and local variables in the calling
function are not available during the execution of the called
function.
- You can obtain a value for a global variable everywhere,
except in functions in which there is a parameter or local
variable that happens to have the same name. You can assign a
value to a global variable anywhere that you can obtain a value
for that variable.
- You can obtain a value for a global constant everywhere,
except in functions in which there is a parameter or local
variable that happens to have the same name, but you cannot
reassign global constants anywhere.