• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. Understanding Scope and Lifet... > Measuring the Lifetime of a Variable...

Measuring the Lifetime of a Variable or Constant

Scope determines which procedures can access a variable or procedure. A variable’s lifetime determines when and for how long that variable is live (active in memory) and can therefore be accessed. To help clarify lifetime, within the context of a variable, here are a few guidelines that will help:

  • Lifetime refers to the time during which a variable retains its value.

  • A variable’s value can change over its lifetime, but the variable retains some value.

  • When a variable loses scope (that is, when the scope where it is defined vanishes) it loses its value, so there is a relationship between scope and lifetime, but they aren’t the same thing.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint