IT SOLUTIONS
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 GuidesASP Classic  Print This     

Constructor (ASP Classic and Delphi Prism Cross Reference Guide)

By Mike Prestwood

ASP Classic versus Delphi Prism: A side by side comparison between ASP Classic and Delphi Prism.

 
OOP Details
 

More object oriented (OO) stuff.

Constructor

[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?

ASP Classic:  "Constructors" Class_Initialize

When an object instance is created from a class, ASP calls a special parameter-less sub named Class_Initialize. Since you cannot specify parameters for this sub, you also cannot overload it.

When a class is destroyed, ASP calls a special sub called Class_Terminate.

Syntax Example:
Class Cyborg
  Public CyborgName
 
 Public Sub Class_Initialize
   Response.Write "<br>Class created"
   CyborgName = "Cameron"
  End Sub 
End Class
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
public
  constructor();
  constructor(pName: String);
end;












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


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