Access control in inheritance in SAP ABAP :-
When a sub-class is derived from any super-class in SAP ABAP then inheritance can be done by different accessible control. There are three accessible control in inheritance
- Public
- Private
- Protected
The type of accessible control needs to define while inheriting the property of parent class depends on the need or demand of the programmer. “Public” access control is used widely while the uses of “Protected” and “Private” access control is very less. The table drawn below shows the accessible of class members with different accessible control.
ACCESS |
Access control key |
||
---|---|---|---|
Public |
Protected |
Private |
|
Same Class |
Yes |
Yes |
Yes |
Derived Class |
Yes |
Yes |
No |
Outside Class |
Yes |
No |
No |
- Public:- The member which is declared public can be accessed from inside and outside the class.
- Protected:- The member which is defined as protected can be accessed within the class and it’s sub-class only.
- Private:- The member which is defined as private can be accessed with the class only.
SAP ABAP | Understanding Inheritance
As we know there are four pillars of object-oriented programming language. In the same way, SAP ABAP (Advanced Business Application Programming) also has four pillars: Encapsulation, Inheritance, Abstraction, and Polymorphism. In this article, we are going to learn about Inheritance in ABAP, child class, Parent class, and access control. We will also learn about the implementation of inheritance with the help of examples and redefining the methods in subclasses.