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
-
Reduced instruction set computer
Processor executing one instruction in minimal clock cycles
Nº Q189376 ★★★
Not listed
-
Dockworker
Occupation of loading and unloading ships
Nº Q1537445 ★★★
Not listed
-
C
CC (complexity)
Complexity class in computational complexity theory
Nº Q5009755 ★
Not listed
-
alarife
Person in charge of overseeing construction works in Medieval Spain
Nº Q10853156 ★★
Not listed
-
Stonemason
Craftsman
Nº Q328325 ★★★
Not listed
-
Author
Writer of an original work
Nº Q482980 ★★★★
Not listed
-
Aircraft pilot
Person controlling an aircraft in flight
Nº Q2095549 ★★★★
Not listed
-
E
Employer
Person or company that employs workers
Nº Q3053337 ★★
Not listed
-
R (programming language)
Programming language for statistical analysis
Nº Q206904 ★★★★★★
Not listed
-
Button (computing)
Graphical user interface element
Nº Q1335171 ★
Not listed
-
Web developer
Programmer who specializes in World Wide Web applications
Nº Q6859454 ★★★
Not listed
-
f
film or television director
Occupation
Nº Q6102247 ★
Not listed
-
T
Technik programista
Nº Q136102067 ★★
Not listed
-
Software developer
Person or company concerned with facets of the software development process
Nº Q183888 ★★★★
Not listed
-
Mediator pattern
Behavioral design pattern defining an object that encapsulates how a set of objects interact
Nº Q1546118 ★
Not listed
-
Sculptor (constellation)
Constellation in the southern celestial hemisphere
Nº Q9286 ★★
Not listed
-
Benefactor (law)
Person who gives some form of help to benefit a person, group or organization (the beneficiary)
Nº Q4887411 ★
Not listed
-
C
Content creator
Occupation involving creating online media content
Nº Q109459317 ★
Not listed