Constructor (object-oriented programming)
Special method used for initializing a newly allocated object in object-oriented programming
In class-based, object-oriented programming, a constructor (abbreviation: ctor) is a special type of function called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.
Nº Q1049476 ★
Common · Knowledge
Constructor (object-oriented programming)
Special method used for initializing a newly allocated object in object-oriented programming
In class-based, object-oriented programming, a constructor (abbreviation: ctor) is a special type of function called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.
From Wikipedia
In class-based, object-oriented programming, a constructor (abbreviation: ctor) is a special type of function called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables. A constructor resembles an instance method, but it differs from a method in that it has no explicit return type, it is not implicitly inherited and it usually has different rules for scope modifiers. Constructors often have the same name as the declaring class. They have the task of initializing the object's data members and of establishing the invariant of the class, failing if the invariant is invalid. A properly written constructor leaves the resulting object in a valid state. Immutable objects must be initialized in a constructor. Most languages allow 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 factories, which also create objects but can do so in various ways, using multiple classes or different allocation schemes such as an object pool.
Text: Wikipédia, CC BY-SA 4.0. · Image: Tevfik AKTUĞLU (CC BY-SA 4.0) ·
Related cards
-
Decompiler
Computer program that transforms low-level code into high-level code
Nº Q913697 ★
Not listed
-
History of compiler construction
Wikimedia history article
Nº Q3502371 ★
Not listed
-
Computer
General-purpose device for performing arithmetic or logical operations
Nº Q68 ★★★★★
Not listed
-
Construct (philosophy)
Ideal object, whose existence depends upon a subject's mind
Nº Q659390 ★★
Not listed
-
P
Property (programming)
Type of class member in object-oriented programming which is accessed like a field but implemented as subroutine(s)
Nº Q2123335 ★
Not listed
-
Roofer
Occupation, worker who works on a roof
Nº Q552378 ★★★
Not listed