Ad Space — Top Banner

E2062

Delphi Programming Language

Severity: Moderate

What Does This Error Mean?

E2062 means you have an abstract method that must be implemented by a subclass, but either the method was called directly or a concrete class failed to implement it. Abstract methods declared with 'abstract' exist only as a contract — calling them directly or instantiating a class that does not implement them causes this error. Fix it by implementing the abstract method in the subclass that is being used.

Affected Models

  • Delphi 10.4 Sydney
  • Delphi 11 Alexandria
  • Delphi 12 Athens
  • Embarcadero RAD Studio
  • Free Pascal / Lazarus

Common Causes

  • Creating an instance of a class that inherits an abstract method without overriding it
  • Calling an abstract method directly on the base class instead of through a subclass instance
  • A subclass that overrides some but not all abstract methods from the parent
  • Using a class reference to create an instance of a class that has unimplemented abstract methods
  • Forgetting to add the override keyword on the implementing method in the subclass

How to Fix It

  1. Find the abstract method declaration in the base class — it is marked with 'virtual; abstract;' or just 'abstract;'.

    Example: procedure DoWork; virtual; abstract; — this method must be implemented in every non-abstract subclass.

  2. In the subclass you are trying to instantiate, add an implementation for the abstract method using the override keyword.

    Example: procedure TConcreteClass.DoWork; override; begin ... end;

  3. Verify that the subclass method signature exactly matches the base class abstract method signature.

    The method name, parameters, return type, and calling convention must all match for override to link correctly.

  4. If the class is intentionally abstract (not meant to be instantiated directly), mark it as abstract at the class level and do not create instances of it.

    Example: type TBaseClass = class abstract ... — this prevents accidental instantiation of the base class.

  5. Check all abstract methods in the inheritance chain — if the base class has multiple abstract methods, every one of them must be overridden.

    Use Ctrl+Space after typing Override to see which methods require overriding in the current class.

When to Call a Professional

This is a compiler error — no professional repair needed. Fix it by reading the error message and correcting the code. The Delphi IDE highlights the exact line causing the problem.

Frequently Asked Questions

What is the purpose of abstract methods in Delphi?

Abstract methods define a contract — they say 'every subclass must provide this behavior' without specifying how. This lets you write code that works with the base class type while knowing each concrete subclass will have its own version of the method. It is the foundation of polymorphism: the same method call does different things depending on the actual object type at runtime.

What happens if you call an abstract method at runtime without overriding it?

If Delphi allows the code to compile (some abstract method calls produce warnings rather than errors), calling an unimplemented abstract method at runtime raises an EAbstractError exception. This is a runtime crash, not a compile error, when abstract method calls are not caught at compile time. Always implement all abstract methods to avoid this.

What is the difference between virtual and abstract in Delphi?

Virtual means the method has a default implementation in the base class that subclasses can optionally override. Abstract means the method has NO implementation in the base class — subclasses MUST provide one. All abstract methods are implicitly virtual, but not all virtual methods are abstract.