Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
Hatnote moved to top of the article; Deleted {{toclimit|3}} tag
Line 1:
{{refimprove|date=August 2010}}
{{ProgLangCompare}}
 
In [[class-based programming|class-based]] [[object-oriented programming]], a '''constructor''' in a [[Class (computer programming)|class]] is a special type of [[subroutine]] called to [[object creation|create an object]]. It prepares the new object for use, often accepting [[argument]]s that the constructor uses to set required [[member variable]]s.
 
Line 9 ⟶ 11:
 
Most languages allow [[method overloading|overloading]] the constructor in that there can be more than one constructor for a class, with differing parameters. Some languages take consideration of some special types of constructors. Constructors, which concretely use a single class to create objects and return a new instance of the class, are abstracted by [[Factory (object-oriented programming)|factories]], which also create objects but can do so in various ways, using multiple classes or different allocation schemes such as an [[object pool]].
{{toclimit|3}}
 
== Types ==
Line 530 ⟶ 531:
 
== References ==
{{refimprove|date=August 2010}}
{{reflist}}