E2072
Delphi Programming Language
Severity: ModerateWhat Does This Error Mean?
E2072 means you called Create on a class that is abstract — it has one or more unimplemented abstract methods. An abstract class is a blueprint that cannot be used directly. You must use a concrete subclass that implements all the abstract methods. Fix it by instantiating a non-abstract subclass instead of the base class.
Affected Models
- Delphi 10.4 Sydney
- Delphi 11 Alexandria
- Delphi 12 Athens
- Embarcadero RAD Studio
- Free Pascal / Lazarus
Common Causes
- Calling TMyAbstractClass.Create directly instead of TConcreteSubclass.Create
- Declaring a class with abstract methods but using it directly without subclassing
- A factory function or class variable using the base class type instead of a concrete subclass
- Forgetting to implement one or more abstract methods in what was intended to be a concrete class
- Using a class reference (metaclass) that points to an abstract class
How to Fix It
-
Identify which class the error names — look at the error message for the class name.
Search for its declaration to understand which of its methods are abstract.
-
Create a subclass that inherits from the abstract class and implements all abstract methods.
Example: type TConcreteAnimal = class(TAbstractAnimal) procedure MakeSound; override; end;
-
Change the instantiation to use the concrete subclass: TConcreteAnimal.Create instead of TAbstractAnimal.Create.
You can still store the reference in a variable declared as the base class type: var A: TAbstractAnimal; A := TConcreteAnimal.Create;
-
If you were using a class reference (TClass or a specific metaclass type), ensure the class reference holds a concrete subclass, not the abstract base.
Abstract classes can be referenced by type but never instantiated.
-
If the class was intended to be concrete (not abstract), find and implement all the abstract methods that are missing in it.
The compiler generates a hint listing which abstract methods are not overridden — read those hints to know what is missing.
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
Why would you create an abstract class if you cannot instantiate it?
Abstract classes define a common interface and shared behavior for a family of related classes. You write code that works with the abstract type (polymorphism) without needing to know which specific subclass it is. For example, TShape could be abstract with an abstract Draw method — TCircle and TRectangle both extend TShape and implement Draw differently.
How do I know if a class is abstract in Delphi?
Look at the class declaration — if any method is declared with 'virtual; abstract;' and is not overridden, the class is effectively abstract. In modern Delphi, you can also declare the entire class as abstract: type TMyClass = class abstract ... The compiler generates a warning (W1023) when you instantiate a class with unimplemented abstract methods.
Can I have a class with some abstract and some non-abstract methods?
Yes — this is the typical pattern. The base class provides common implementation in non-abstract methods and declares abstract methods for behavior that varies per subclass. Subclasses inherit the non-abstract implementations and must provide their own versions of the abstract methods. This avoids code duplication while enforcing the contract.