Talk:Class variable
![]() | This article is rated Stub-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||||||
|
Shared across instances
[edit]not sure where i'm supposed to put this, top or bottom, but this is an incorrect definition. in many oop languages, including c# and java, a class member variable or (class variable) for short is instance agnostic. e.g. it can either be a static or an instance variable. can someone fix this? -bc —Preceding unsigned comment added by 64.125.183.186 (talk) 18:53, 25 June 2010 (UTC)
- fuck it. i fixed it. vera, your definition here is incorrect. - bc —Preceding unsigned comment added by 76.95.140.83 (talk) 20:50, 3 July 2010 (UTC)
- Actually, class variable values are by definition shared by all instances of a class, and instance variables can never be class variables. See [1] for an explanation of this for Java and [2] for a Python one. Even Objective C, which does not have a dedicated class variable syntax, recognizes the concept of class variables as distinct from instance variables in its runtime reference at [3]. I will edit the article to remove any confusion about this and add citations. Links to references for other object-oriented languages' use of the "class variable" term would be very welcome, particularly links to C# and C++ references. -cph --173.226.146.65 (talk) 18:49, 21 October 2010 (UTC)
2003 edits
[edit]Vera Cruz, please hold your horses on these multiple edits within a short time span. This is neither the correct name for this article nor the correct definition.
The correct name is class data member and in the the definition it should be made clear that when you say all instances share the member that we are not talking about static members, and indicate that static members have one instance across all instances of the class. Mintguy — Preceding undated comment added 16:20, 16 January 2003
- I see what you're doing now. But I think class variable is the Java name for the term, static data member is the C++ name for the term. I'm not sure what the correct OOP name is. Mintguy — Preceding undated comment added 16:26, 16 January 2003
"Static field" listed at Redirects for discussion
[edit]
A discussion is taking place to address the redirect Static field. The discussion will occur at Wikipedia:Redirects for discussion/Log/2021 June 17#Static field until a consensus is reached, and readers of this page are welcome to contribute to the discussion. - Jay (Talk) 07:16, 18 June 2021 (UTC)
Start a discussion about improving the Class variable page
Talk pages are where people discuss how to make content on Wikipedia the best that it can be. You can use this page to start a discussion with others about how to improve the "Class variable" page.