Delphi Programming
Advertisement
Stub
This article is a stub.
Please help enhance the Delphi Programming Wiki by expanding it.

A unit is a Delphi source file(*.pas). It contains interface, class, type and method declarations and implementations. Unlike some other languages (such as C or C++) which have a separate header file for declarations which is 'included' in the code file, Delphi's units contain all required information for both declarations and implementations in a single file.

Each unit is stored in its own file and compiled separately. Compiled units are linked to create an application. Compiled unit file has (*.dcu) extension.

Units are referenced by other units by being listed in that unit's uses clause.

A unit file begins with a unit heading, which is followed by the sections:

  • interface
  • implementation
  • initialization (optional)
  • finalization (optional)

The unit must conclude with the word end followed by a period.

Advertisement