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
-
M
Monitor (synchronization)
In concurrent programming, an object or module intended to be used safely by more than one thread
Nº Q1062162 ★
Not listed
-
Network administrator
Individual that is responsible for the maintenance of computer hardware and software systems that make up a computer network
Nº Q680296 ★★★
Not listed
-
skipper
Person responsible in a recreational or professional ship
Nº Q1897112 ★★★
Not listed
-
c
construction mechanic
German training occupation
Nº Q1782987 ★
Not listed
-
A
Abstract data type
Mathematical model for data types
Nº Q827335 ★★
Not listed
-
Tor (network)
Daemon and utilities for an anonymizing network
Nº Q202044 ★★★★★
Not listed
-
C
Concurrent computing
Form of computing in which several computations logically execute during overlapping time periods
Nº Q128392 ★★
Not listed
-
P
Promoter (entertainment)
Individual or company that promotes live entertainment events
Nº Q2378505 ★★★
Not listed
-
G
Germ (mathematics)
Equivalence class of objects sharing local properties at a point in a topological space
Nº Q2520842 ★
Not listed
-
L
Load–store architecture
Type of instruction set architecture
Nº Q6663274 ★
Not listed
-
C--
C-like programming language
Nº Q81348 ★★
Not listed
-
Web crawler
Internet bot that systematically browses the World Wide Web, typically for the purpose of Web indexing (web spidering)
Nº Q45842 ★★★
Not listed
-
a
amateur astronomer
Occupation
Nº Q11442656 ★
Not listed
-
Niche (architecture)
Architectural recess in a wall
Nº Q695992 ★★
Not listed
-
Butcher
Craftsman responsible for the preparation and sale of meat
Nº Q329737 ★★★
Not listed
-
Countertenor
High classical male singing voice
Nº Q223166 ★★★
Not listed
-
Personal computer
Computer intended for use by an individual person
Nº Q16338 ★★★★
Not listed
-
u
uploader
Someone who uploads video, audio, or other resources online
Nº Q18651180 ★★★
Not listed