Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesDelphi PrismTool Basics  Print This     

Constructor (Cross Ref > Tool Basics)

By Mike Prestwood

Delphi Prism versus C++: A side by side comparison between Delphi Prism and C++.

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 Prism:  "Constructors" constructor + class name

In Prism, a constructor is called whenever a class or struct is created. You use the constructor keyword with an unnamed method. You can overload the constructor simply by adding two or more unnamed methods with various parameters.

Prism also supports a Create constructor method for backward compatibility with Delphi for Win32.

If you do not create a constructor, Prism will create an implicit constructor that initializes all member fields to their default values.

Constructors can execute at two different times. Static constructors are executed by the CLR before any objects are instantiated. Regular constructors are executed when you create an object.

Syntax Example:
Cyborg = public class
  constructor(pName: String);
C++:  "Constructors" Use Class name

A member function with the same name as the class.

Syntax Example:  
class X {
X(); // constructor for class X

Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site:

©1995-2023 Prestwood IT Solutions.   [Security & Privacy]