Difference between revisions of "Class variable"
From Wiki @ Karl Jones dot com
Karl Jones (Talk | contribs) (Created page with "In object-oriented programming with classes, a '''class variable''' is a variable defined in a class of which a...") |
Karl Jones (Talk | contribs) |
||
Line 1: | Line 1: | ||
− | In [[object-oriented programming]] with classes, a '''class variable''' is a [[Variable ( | + | In [[object-oriented programming]] with classes, a '''class variable''' is a [[Variable (computer science)|variable]] defined in a [[Class (computer programming)|class]] of which a single copy exists, regardless of how many [[Instance (computer science)|instances]] of the class exist. |
A class variable is not an instance variable. It is a special type of class attribute (or class property, field, or data member). The same dichotomy between instance and class members applies to methods ("member functions") as well; a class may have both instance methods and class methods. | A class variable is not an instance variable. It is a special type of class attribute (or class property, field, or data member). The same dichotomy between instance and class members applies to methods ("member functions") as well; a class may have both instance methods and class methods. | ||
Line 8: | Line 8: | ||
* [[Instance (computer science)]] | * [[Instance (computer science)]] | ||
* [[Object-oriented programming]] | * [[Object-oriented programming]] | ||
− | * [[Variable ( | + | * [[Variable (computer science)]] |
== External links == | == External links == |
Latest revision as of 13:34, 24 August 2016
In object-oriented programming with classes, a class variable is a variable defined in a class of which a single copy exists, regardless of how many instances of the class exist.
A class variable is not an instance variable. It is a special type of class attribute (or class property, field, or data member). The same dichotomy between instance and class members applies to methods ("member functions") as well; a class may have both instance methods and class methods.
See also
- Class (computer programming)
- Instance (computer science)
- Object-oriented programming
- Variable (computer science)
External links
- Class variable @ Wikipedia