When an object is first created, it initializes all its fields to
default values. This occurs in the TObject.InitInstance
method. The following table shows the values for all Delphi’s kinds
of types. In particular, note that there will be no “undefined”
values in any of the fields.
Table 1
Default field values
| Type | Value |
|---|---|
| Byte, ShortInt, Word, SmallInt, LongInt, LongWord, Int64 | 0 |
| Single, Real48, Double, Extended | 0.0 |
| Boolean, ByteBool, WordBool, LongBool | False |
| Enumerated type T | T(0) |
| Set | [] |
| ShortString, AnsiString, WideString | '' |
| AnsiChar, WideChar | #0 |
| TObject, IUnknown, Pointer, dynamic array, procedure pointer, method pointer | nil |
| Variant | Unassigned |
| Static array | The elements all get the initial value corresponding to their type in this table |
| Record | Each field gets the initial value corresponding to its type in this table |