Instance variable

From Conservapedia
This is an old revision of this page, as edited by Ed Poor (talk | contribs) at 12:08, December 21, 2008. It may differ significantly from current revision.
Jump to navigation Jump to search

An instance variable is a variable which available only to one instance of a class. It is the object's own property. For example, a particular square may be 4 inches wide. Other squares may have different widths.

A class variable, by contrast, is available to all instances of a class. It is a property which is the same for all objects. For example, the interior angle of every square is 90 degrees, no matter how wide the square is.