Difference between revisions of "Constructor"

From Free Pascal wiki
Jump to navigationJump to search
(Use pascal highlighter)
Line 6: Line 6:
 
Example:  
 
Example:  
  
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
// class definition
 
// class definition
 
type
 
type

Revision as of 17:26, 29 January 2020

Deutsch (de) English (en) español (es) suomi (fi) русский (ru)

The reserved word constructor belongs to object-oriented programming. Constructor is a class builder method that creates the object of that class.

Example:

// class definition
type
  TKlasse = class
  end;

var
  // declare variable of type of class
  clsKlasse: TKlasse;

begin
  ...
  // create class
  clsKlasse := TKlasse.Create; 
  ...
end;

See also