Object Pascal
In Object Pascal, the constructor is similar to a factory method. The only syntactic difference to regular methods is the keyword constructor
in front of the name (instead of procedure
or function
). It can have any name, though the convention is to have Create
as prefix, such as in CreateWithFormatting
. Creating an instance of a class works like calling a static method of a class: TPerson.Create('Peter')
.
Read more about this topic: Constructor (object-oriented Programming)
Famous quotes containing the words object and/or pascal:
“Agreeable then to my present inclination, I formed the object of my own worship, which was no other than my own understanding.”
—Sarah Fielding (17101768)
“Truly it is an evil to be full of faults; but it is a still greater evil to be full of them and to be unwilling to recognize them, since that is to add the further fault of a voluntary illusion.”
—Blaise Pascal (16231662)