The next part of the code consists in how you can inherit classes. This is a powerful concept because you get functionality that already exists and depending on the definition, it is possible to change the behaviour of a method.
class cl_dog definition inheriting from cl_animal. public section. methods: constructor importing i_dog_name type string, make_a_sound redefinition. " Change the behaviour of the method. Reimplement the code. endclass. class cl_dog implementation. method constructor. super->constructor( i_dog_name ). " Initialize the constructor and internally pass the parameter to the abstract class p_class = '"Dog"'. " This is the protected member which is visible only in child classes endmethod. method make_a_sound. write: / 'My sound is:', 'Woof, woof'. endmethod. endclass. Serkan AKKAVAK Computer Engineer ABAP Developer & SAP S/4 HANA Logistics Team Lead Contact : serkurumsal@yandex.com |
Social Plugin