Search: in
Class variable
Class variable in Encyclopedia Encyclopedia
  Tutorials     Encyclopedia     Videos     Books     Software     DVDs  

Class variable

In object-oriented programming with classes, a class variable is a variable defined in a class (i.e. a member variable) of which a single copy exists, regardless of how many instances of the class exist.[1][2][3][4]

A class variable is the opposite of an instance variable. It is a special type of class attribute (or class property, field, or data member).

In Java, C#, and C++, class variables are declared with the keyword static, and may therefore be referred to as static member variables.

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. Again, Java, C#, and C++ use the keyword static to indicate that a method is a class method ("static member function").


In this C++ example, the class variable Request::count is incremented on each call to the constructor, so that Request::count always holds the number of Requests that have been constructed, and each new Request object is given a number in sequential order. Since count is a class variable, there is only one object Request::count; in contrast, each Request object contains its own distinct number field.


ca:Variable de classe es:Variable de clase ja: ta:

Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article

Search for Class variable in Tutorials
Search for Class variable in Encyclopedia
Search for Class variable in Videos
Search for Class variable in Books
Search for Class variable in Software
Search for Class variable in DVDs
Search for Class variable in Store


Class variable in Encyclopedia
Class_variable top Class_variable

Home - Add TutorGig to Your Site - Disclaimer

©2011-2013 All Rights Reserved. Privacy Statement