Difference between revisions of "Member variable"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Created page with "In object-oriented programming, a '''member variable''' (sometimes called a '''member field''') is a variable that is associated with a specific object, and accessible for...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
In [[object-oriented programming]], a '''member variable''' (sometimes called a '''member field''') is a variable that is associated with a specific object, and accessible for all its methods (member functions).
+
In [[object-oriented programming]], a '''member variable''' (sometimes called a '''member field''') is a [[Variable (computer science)|variable]] that is associated with a specific object, and accessible for all its methods (member functions).
  
 
== Types in class-based language ==
 
== Types in class-based language ==
  
In class-based languages, these are distinguished into two types:  
+
In [[Class (computer science)|class]]-based languages, these are distinguished into two types:  
  
* If there is only one copy of the variable shared with all instances of the class, it is called a class variable or static member variable
+
* If there is only one copy of the variable shared with all instances of the class, it is called a [[class variable]] or static member variable
* If each instance of the class has its own copy of the variable, the variable is called an instance variable.
+
* If each instance of the class has its own copy of the variable, the variable is called an [[instance variable]].
  
 
== See also ==
 
== See also ==
  
 +
* [[Attribute (computing)]] - a specification that defines a property of an [[Object (computer science)|object]], [[HTML element|element]], [[Computer file|file]], etc.
 +
* [[Class (computer programming)]]
 +
* [[Global variable]]
 +
* [[Instance variable]]
 +
* [[Local variable]]
 
* [[Object-oriented programming]]
 
* [[Object-oriented programming]]
 +
* [[Variable (computer science)]]
  
 
== External links ==
 
== External links ==

Latest revision as of 09:02, 4 September 2016

In object-oriented programming, a member variable (sometimes called a member field) is a variable that is associated with a specific object, and accessible for all its methods (member functions).

Types in class-based language

In class-based languages, these are distinguished into two types:

  • If there is only one copy of the variable shared with all instances of the class, it is called a class variable or static member variable
  • If each instance of the class has its own copy of the variable, the variable is called an instance variable.

See also

External links