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
-
Compiler
Computer program that transforms source code into object code
Nº Q47506 ★★★
Not listed
-
Von Neumann architecture
Computer architecture using a common memory bus and address space for instructions and data
Nº Q189088 ★★★★
Not listed
-
C
Cury Construtora
Nº Q30932549 ★★★
Not listed
-
Lex (software)
Standard UNIX utility
Nº Q306650 ★
Not listed
-
Plasterer
Profession; tradesman who works with plaster
Nº Q15284879 ★★★
Not listed
-
Scheduling (computing)
In computing, what carries out the scheduling activity
Nº Q1123036 ★★
Not listed
-
C
Commutator
Two similar notions: in group theory and in ring theory
Nº Q2989763 ★★
Not listed
-
W
Web designer
Professional who designs websites
Nº Q11288554 ★
Not listed
-
S
Software analyst
Profession in IT
Nº Q2058241 ★
Not listed
-
P
Property developer
Individual or company that coordinates the process of real estate or property development
Nº Q17487600 ★★★
Not listed
-
storyteller
One who tells stories (not a narrator)
Nº Q12869138 ★★
Not listed
-
Mechanic
Profession
Nº Q327029 ★★★
Not listed
-
T
Translator (computing)
Computer program that translates from one programming language to another
Nº Q4462013 ★★
Not listed
-
Lokator
Medieval surveyor
Nº Q129536 ★★
Not listed
-
p
project designer (construction)
Agent in Spanish building law (LOE) who authors the project documentation
Nº Q9063418 ★
Not listed
-
Sculptor
Artist specializing in sculpture
Nº Q1281618 ★★★
Not listed
-
e
expeditor
Profession
Nº Q4414015 ★★
Not listed
-
M
Monitor (synchronization)
In concurrent programming, an object or module intended to be used safely by more than one thread
Nº Q1062162 ★
Not listed