Using Delphi Objects

As mentioned earlier, objects (also called classes) are entities that can contain both data and code. Delphi objects also provide you with all the power of object-oriented programming in offering full support of inheritance, encapsulation, and polymorphism.

Declaration and Instantiation

Of course, before using an object, you must have declared an object using the class keyword. As described earlier in this chapter, objects are declared in the type section of a unit or program:

type
  TFooObject = class;

In addition to an object type, you usually also will have a variable of that class type, or instance, declared in the var section:

var
  FooObject: TFooObject;

You create an instance of an object in Object Pascal by calling ...

Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.