Jump to content

Method (computer programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by TakuyaMurata (talk | contribs) at 01:15, 24 May 2003 (make a new article). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

A method is a special kind of subprogram belonging to class.

An instance method is a method invoked with respect to an instance of a class. Instance methods are often used to examine or modify the state of a particular object. In Java and C++, constructors are instance methods which have the same name as their class. In typical implementations, instance methods take a hidden reference to the object they belong to.

In contrast to instant methods, a class method (a.k.a static method, shared method) can be invoked without reference to a particular object. These affect an entire 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.

An abstract method is a method which has no implementation. It is used to make a place-holder to be overriden later.