Abstract

Belongs to : Directive

Description

The Abstract directive defines a class method as being implemented only in derived classes. It is abstract in the sense that it is a placeholder – it has no implementation in the current class, but must be implemented in any derived classes.

It is used where the base class is always treated as a skeleton class. Where such a class is never directly used – only based classes are ever instantiated into objects.

For example, a TAnimal class may have an abstract method for how the animal moves. Only when creating, say, a TCat class based in TAnimal will you implement the method. In this instance, the cat moves by walking.

An Abstract class must be used to qualify a virtual class, since we are not implementing the class (see Virtual for more details).

Notes
If you create an instance of a class that has an Abstract method, then delphi warns you that it contains an uncallable method.
If you then try to call this method, Delphi will try to call AbstractErrorProc. If not found, it will throw an EAbstractError exception.




Example code