Constructor: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | - | ||
| 1 | + | The [[Reserved word|reserved word]] `constructor` belongs to [[object-oriented programming]]. `Constructor` is a [[Class|class]] builder [[Method|method]] that creates the object of that class. | |
| 4 | 2 | ||
| 5 | - | ||
| 3 | + | Example: | |
| 4 | + | ``` | |
| 6 | 5 | // class definition | |
| 7 | - | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 6 | + | type | |
| 7 | + | TKlasse = class | |
| 8 | + | end; | |
| 9 | + | ||
| 10 | + | var | |
| 11 | + | // declare variable of type of class | |
| 12 | + | clsKlasse: TKlasse; | |
| 13 | + | ||
| 14 | + | begin | |
| 15 | + | ... | |
| 16 | + | // create class | |
| 17 | + | clsKlasse := TKlasse.Create; | |
| 18 | + | ... | |
| 19 | + | end; | |
| 21 | 20 | ``` | |
| 22 | 21 | ||
| 23 | 22 | ## See also | |
| 24 | 23 | ||
| 25 | - | ||
| 24 | + | * [[Destructor]] | |
| 26 | 25 | ||
| 27 | 26 | --- | |
| 28 | - | ||
| 27 | + | *From the Free Pascal wiki, page "Constructor", as the Internet Archive kept it on 2024-02-05. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
