Method (computer programming): Difference between revisions

Content deleted Content added
Aion (talk | contribs)
wikified
clarify static method as shared method
Line 12:
An '''instance method''' is a method invoked with respect to an [[instance]] of a [[class (computer science)|class]]. Instance methods are often used to examine or modify the [[state]] of a particular [[object (computer science)|object]]. In [[Java programming language|Java]] and [[C Plus Plus|C++]], '''constructors''' are special instance methods that are called automatically upon the [[object creation|creation]] of an instance of a class; they are distinguished by having the same name as their class. In typical implementations, instance methods are passed a hidden reference to the object they belong to, so that they can access the data associated with the instance that they are called upon.
 
In contrast to instance methods, a '''class method''' (a.k.a '''static method''', '''shared method''') can be invoked without reference to a particular [[object (computer science)|object]]. These affect an entire [[Class (computer science)|class]], not merely a particular instance of the class. A typical example of a class method would be one that keeps count of the number of created objects within a given class. Some programming languages such as C++ and Java call them '''static method''' since methods are modified with <code>static</code>.
 
An '''abstract method''' is a [[method]] which has no [[implementation]]. It is used to make a place-holder to be overridden later.