I.T. Discussion Community!
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesDelphi  Print This     

Constructor (Delphi and Perl Cross Reference Guide)

By Mike Prestwood

Delphi versus Perl: A side by side comparison between Delphi and Perl.

OOP Details

More object oriented (OO) stuff.


[Other Languages] 

General Info: Class Constructor

Constructors are called when you instantiate an object from a class. This is where you can initialize variables and put code you wish executed each time the class is created. When you initially set the member fields and properties of an object, you are initializing the state of the object. The state of an object is the values of all it's member fields and properties at a given time.

Languages Focus

What is the syntax? Can you overload constructors? Is a special method name reserved for constructors?

Delphi:  "Constructors" constructor

In Delphi, use the constructor keyword to signify which method or methods are constructors for a class. It is traditional but not required to use a procedure called Create.

In addition to having multiple named constructors, you can overload constructors.

Syntax Example:
//Interface section.
TCyborg = class(TObject)
  constructor Create;

Then implement the class constructor in the Implementation section.

constructor TCyborg.Create;
  inherited;  //Call the parent Create method
[Not specified yet. Coming...]

Follow PrestwoodBoards on: 

©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech