<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Member_variable</id>
	<title>Member variable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Member_variable"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Member_variable&amp;action=history"/>
	<updated>2026-05-06T15:54:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Member_variable&amp;diff=5564537&amp;oldid=prev</id>
		<title>imported&gt;TarnishedPath: Per page move: Changed link from Class (computer programming) to Class (programming) using MovePlus</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Member_variable&amp;diff=5564537&amp;oldid=prev"/>
		<updated>2025-10-17T09:14:19Z</updated>

		<summary type="html">&lt;p&gt;Per page move: Changed link from &lt;a href=&quot;/wiki143/index.php?title=Class_(computer_programming)&quot; class=&quot;mw-redirect&quot; title=&quot;Class (computer programming)&quot;&gt;Class (computer programming)&lt;/a&gt; to &lt;a href=&quot;/wiki143/index.php?title=Class_(programming)&quot; title=&quot;Class (programming)&quot;&gt;Class (programming)&lt;/a&gt; using &lt;a href=&quot;/wiki143/index.php?title=User:TarnishedPath/MovePlus.js&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User:TarnishedPath/MovePlus.js (page does not exist)&quot;&gt;MovePlus&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Previous revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:14, 17 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l2&quot;&gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In [[object-oriented programming]], a &amp;#039;&amp;#039;&amp;#039;member variable&amp;#039;&amp;#039;&amp;#039; (sometimes called a &amp;#039;&amp;#039;&amp;#039;member [[Field (computer science)|field]]&amp;#039;&amp;#039;&amp;#039;) is a [[variable (programming)|variable]] that is associated with a specific [[Object (computer science)|object]], and accessible for all its [[method (computer science)|methods]] (&amp;#039;&amp;#039;member functions&amp;#039;&amp;#039;).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In [[object-oriented programming]], a &amp;#039;&amp;#039;&amp;#039;member variable&amp;#039;&amp;#039;&amp;#039; (sometimes called a &amp;#039;&amp;#039;&amp;#039;member [[Field (computer science)|field]]&amp;#039;&amp;#039;&amp;#039;) is a [[variable (programming)|variable]] that is associated with a specific [[Object (computer science)|object]], and accessible for all its [[method (computer science)|methods]] (&amp;#039;&amp;#039;member functions&amp;#039;&amp;#039;).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In [[class-based programming]] languages, these are distinguished into two types: &#039;&#039;[[class variable]]s&#039;&#039; (also called &#039;&#039;static member variables&#039;&#039;), where only one copy of the variable is shared with all [[instance (computer science)|instance]]s of the [[Class (&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;computer &lt;/del&gt;programming)|class]]; and &#039;&#039;[[instance variable]]s&#039;&#039;, where each instance of the class has its own independent copy of the variable.&amp;lt;ref&amp;gt;{{cite web | accessdate = 2011-08-12 | author = Richard G. Baldwin | date = 1999-03-10 | publisher = Richard G Baldwin Programming Tutorials | title = Q - What is a member variable? | quote = A member variable is a member of a class (class variable) or a member of an object instantiated from that class (instance variable). It must be declared within a class, but not within the body of a method of the class. | url = http://www.dickbaldwin.com/java/Java020.htm}}&amp;lt;/ref&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In [[class-based programming]] languages, these are distinguished into two types: &#039;&#039;[[class variable]]s&#039;&#039; (also called &#039;&#039;static member variables&#039;&#039;), where only one copy of the variable is shared with all [[instance (computer science)|instance]]s of the [[Class (programming)|class]]; and &#039;&#039;[[instance variable]]s&#039;&#039;, where each instance of the class has its own independent copy of the variable.&amp;lt;ref&amp;gt;{{cite web | accessdate = 2011-08-12 | author = Richard G. Baldwin | date = 1999-03-10 | publisher = Richard G Baldwin Programming Tutorials | title = Q - What is a member variable? | quote = A member variable is a member of a class (class variable) or a member of an object instantiated from that class (instance variable). It must be declared within a class, but not within the body of a method of the class. | url = http://www.dickbaldwin.com/java/Java020.htm}}&amp;lt;/ref&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Examples ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Examples ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>imported&gt;TarnishedPath</name></author>
	</entry>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Member_variable&amp;diff=989980&amp;oldid=prev</id>
		<title>imported&gt;Zaelzo: change title of examples section from &quot;For Examples&quot; to &quot;Examples&quot;</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Member_variable&amp;diff=989980&amp;oldid=prev"/>
		<updated>2025-01-13T05:04:31Z</updated>

		<summary type="html">&lt;p&gt;change title of examples section from &amp;quot;For Examples&amp;quot; to &amp;quot;Examples&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Variable associated with a specific object, and accessible for all its methods}}&lt;br /&gt;
In [[object-oriented programming]], a &amp;#039;&amp;#039;&amp;#039;member variable&amp;#039;&amp;#039;&amp;#039; (sometimes called a &amp;#039;&amp;#039;&amp;#039;member [[Field (computer science)|field]]&amp;#039;&amp;#039;&amp;#039;) is a [[variable (programming)|variable]] that is associated with a specific [[Object (computer science)|object]], and accessible for all its [[method (computer science)|methods]] (&amp;#039;&amp;#039;member functions&amp;#039;&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
In [[class-based programming]] languages, these are distinguished into two types: &amp;#039;&amp;#039;[[class variable]]s&amp;#039;&amp;#039; (also called &amp;#039;&amp;#039;static member variables&amp;#039;&amp;#039;), where only one copy of the variable is shared with all [[instance (computer science)|instance]]s of the [[Class (computer programming)|class]]; and &amp;#039;&amp;#039;[[instance variable]]s&amp;#039;&amp;#039;, where each instance of the class has its own independent copy of the variable.&amp;lt;ref&amp;gt;{{cite web | accessdate = 2011-08-12 | author = Richard G. Baldwin | date = 1999-03-10 | publisher = Richard G Baldwin Programming Tutorials | title = Q - What is a member variable? | quote = A member variable is a member of a class (class variable) or a member of an object instantiated from that class (instance variable). It must be declared within a class, but not within the body of a method of the class. | url = http://www.dickbaldwin.com/java/Java020.htm}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Foo {&lt;br /&gt;
    int bar; // Member variable&lt;br /&gt;
  public:&lt;br /&gt;
    void setBar(const int newBar) { &lt;br /&gt;
      bar = newBar;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main () {&lt;br /&gt;
  Foo rect; // Local variable&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class Program&lt;br /&gt;
{&lt;br /&gt;
    public static void main(String[] args)&lt;br /&gt;
    {&lt;br /&gt;
    	// This is a local variable. Its lifespan&lt;br /&gt;
    	// is determined by lexical scope.&lt;br /&gt;
    	Foo foo;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Foo&lt;br /&gt;
{&lt;br /&gt;
    /* This is a member variable - a new instance&lt;br /&gt;
     of this variable will be created for each &lt;br /&gt;
     new instance of Foo.  The lifespan of this&lt;br /&gt;
     variable is equal to the lifespan of &amp;quot;this&amp;quot;&lt;br /&gt;
     instance of Foo&lt;br /&gt;
    */&lt;br /&gt;
&lt;br /&gt;
    int bar;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class Foo:&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        self._bar = 0&lt;br /&gt;
&lt;br /&gt;
    @property&lt;br /&gt;
    def bar(self):&lt;br /&gt;
        return self._bar&lt;br /&gt;
&lt;br /&gt;
    @bar.setter&lt;br /&gt;
    def bar(self, new_bar):&lt;br /&gt;
        self._bar = new_bar&lt;br /&gt;
&lt;br /&gt;
f = Foo()&lt;br /&gt;
f.bar = 100&lt;br /&gt;
print(f.bar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Common Lisp ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(defclass foo () (bar))                                                         &lt;br /&gt;
                                                                                &lt;br /&gt;
(defvar f (make-instance &amp;#039;foo))                                                 &lt;br /&gt;
(setf (slot-value f &amp;#039;bar) 100)&lt;br /&gt;
(print (slot-value f &amp;#039;bar))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
  Ruby has three member variable types: class, class instance, and instance.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
class Dog&lt;br /&gt;
&lt;br /&gt;
  # The class variable is defined within the class body with two at-signs&lt;br /&gt;
  # and describes data about all Dogs *and* their derived Dog breeds (if any)&lt;br /&gt;
  @@sniffs = true&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
mutt = Dog.new&lt;br /&gt;
mutt.class.sniffs #=&amp;gt; true&lt;br /&gt;
&lt;br /&gt;
class Poodle &amp;lt; Dog&lt;br /&gt;
&lt;br /&gt;
  # The &amp;quot;class instance variable&amp;quot; is defined within the class body with a single at-sign&lt;br /&gt;
  # and describes data about only the Poodle class. It makes no claim about its parent class&lt;br /&gt;
  # or any possible subclass derived from Poodle&lt;br /&gt;
  @sheds = false&lt;br /&gt;
&lt;br /&gt;
  # When a new Poodle instance is created, by default it is untrained. The &amp;#039;trained&amp;#039; variable&lt;br /&gt;
  # is local to the initialize method and is used to set the instance variable @trained&lt;br /&gt;
  # An instance variable is defined within an instance method and is a member of the Poodle instance&lt;br /&gt;
  def initialize(trained = false)&lt;br /&gt;
    @trained = trained&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def has_manners?&lt;br /&gt;
    @trained&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p = Poodle.new&lt;br /&gt;
p.class.sheds #=&amp;gt; false&lt;br /&gt;
p.has_manners? #=&amp;gt; false&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PHP ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
class Example&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * Example instance member variable.&lt;br /&gt;
     *&lt;br /&gt;
     * Member variables may be public, protected or private.&lt;br /&gt;
     *&lt;br /&gt;
     * @var int&lt;br /&gt;
     */&lt;br /&gt;
    public int $foo;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Example static member variable.&lt;br /&gt;
     *&lt;br /&gt;
     * @var bool&lt;br /&gt;
     */&lt;br /&gt;
    protected static int $bar;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Example constructor method.&lt;br /&gt;
     *&lt;br /&gt;
     * @param int $foo&lt;br /&gt;
     */&lt;br /&gt;
    public function __construct(int $foo)&lt;br /&gt;
    {&lt;br /&gt;
        // Sets foo.&lt;br /&gt;
        $this-&amp;gt;foo = $foo;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Create a new Example object.&lt;br /&gt;
// Set the &amp;quot;foo&amp;quot; member variable to 5.&lt;br /&gt;
$example = new Example(5);&lt;br /&gt;
&lt;br /&gt;
// Overwrite the &amp;quot;foo&amp;quot; member variable to 10.&lt;br /&gt;
$example-&amp;gt;foo = 10;&lt;br /&gt;
&lt;br /&gt;
// Prints 10.&lt;br /&gt;
echo $example-&amp;gt;foo;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Lua ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--region example&lt;br /&gt;
--- @class example_c&lt;br /&gt;
--- @field foo number Example &amp;quot;member variable&amp;quot;.&lt;br /&gt;
local example_c = {}&lt;br /&gt;
local example_mt = {__index = example_c}&lt;br /&gt;
&lt;br /&gt;
--- Creates an object from example.&lt;br /&gt;
--- @return example_c&lt;br /&gt;
function example_c.new(foo)&lt;br /&gt;
  -- The first table argument is our object&amp;#039;s member variables.&lt;br /&gt;
  -- In a Lua object is a metatable and its member variables are table key-value pairs.&lt;br /&gt;
  return setmetatable({&lt;br /&gt;
    foo = foo&lt;br /&gt;
  }, example_mt)&lt;br /&gt;
end&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
-- Create an example object.&lt;br /&gt;
-- Set the &amp;quot;foo&amp;quot; member variable to 5.&lt;br /&gt;
local example = example_c.new(5)&lt;br /&gt;
&lt;br /&gt;
-- Overwrite the &amp;quot;foo&amp;quot; member variable to 10.&lt;br /&gt;
example.foo = 10&lt;br /&gt;
&lt;br /&gt;
-- Prints 10.&lt;br /&gt;
print(example.foo)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Global variable]]&lt;br /&gt;
* [[Local variable]]&lt;br /&gt;
* [[Property (programming)]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Object-oriented programming]]&lt;br /&gt;
[[Category:Variable (computer science)]]&lt;br /&gt;
[[Category:Articles with example Python (programming language) code]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Zaelzo</name></author>
	</entry>
</feed>