Constructor/es: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 1 | + | La palabra reservada constructor es parte de la programación orientada a objetos y se utiliza para inicializar una clase. Las clases simples que no requieren inicialización, no necesitan un constructor. Una clase auto-escrita que no tiene ningún constructor puede heredar el constructor de su clase principal (si tiene un constructor). | |
| 2 | 2 | ||
| 3 | - | ||
| 4 | - | ||
| 3 | + | Ejemplo: | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 5 | 6 | // Definición de la calse | |
| 6 | - | ||
| 7 | - | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 7 | + | type | |
| 8 | + | TClase = class | |
| 9 | + | end; | |
| 10 | + | ||
| 11 | + | var | |
| 12 | + | unaClase: TClase; // Declarar una variable del tipo TClase | |
| 13 | + | ||
| 14 | + | begin | |
| 15 | + | ... | |
| 16 | + | // Crear la clase | |
| 17 | + | unaClase := TClase.Create; // Create invoca al constructor heredado de la clase primaria | |
| 18 | + | ... | |
| 19 | + | end; | |
| 19 | 20 | ``` | |
| 20 | 21 | ||
| 21 | 22 | --- | |
| 22 | - | ||
| 23 | + | *From the Free Pascal wiki, page "Constructor/es", as it stood on 2020-01-29 after a change by Bart, out of the wiki's dump of 2024-05-26. 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).* | |
| 24 | + | Category: Castellano | |
| 25 | + | Category: Español | |
| 26 | + | Category: Reserved words/es |
