ABAP ABAP Objects Inheritance - definition


Example

Information

Inheritance allows you to derive a new class from an existing class. You do this using the INHERITING FROM addition in the

CLASS subclass DEFINITION INHERITING FROM superclass.

statement. The new class subclass inherits all of the components of the existing class superclass. The new class is called the subclass of the class from which it is derived. The original class is called the superclass of the new class. A class can have more than one direct subclass, but it may only have one direct superclass.

Class implementation

CLASS lcl_vehicle DEFINITION.
ENDCLASS.

CLASS lcl_vehicle IMPLEMENTATION.
ENDCLASS.

CLASS lcl_car DEFINITION INHERITING FROM lcl_vehicle.
ENDCLASS.

CLASS lcl_car IMPLEMENTATION.
ENDCLASS.