Thursday 12 July 2012

example for super keyword


CLASS a1 DEFINITION.
  PUBLIC SECTION.
  METHODs: constructor.
  ENDCLASS.
  CLASS a2 DEFINITION INHERITING FROM a1.
   PUBLIC SECTION.
   METHODs: constructor.
   ENDCLASS.

   class a3 DEFINITION INHERITING FROM a2.
   PUBLIC SECTION.
   METHODS: constructor.
   ENDCLASS.


 class a1 IMPLEMENTATION.

 METHOD: constructor.

 write:/ 'MY first constructor'.

 ENDMETHOD.
 ENDCLASS.



CLASS a2 IMPLEMENTATION.

 METHOD: constructor.
   CALL METHOD Super->constructor.
   WRITE:/ 'This is my second constructor'.
   ENDMETHOD.
   ENDCLASS.

class a3 IMPLEMENTATION.
  METHOD:constructor.
   call METHOD super->constructor.
   write:/ ' This is my third constructor'.
   ENDMETHOD.
   ENDCLASS.



 START-OF-SELECTION.

 DATA: obj TYPE REF TO a3.

 CREATE OBJECT obj.

No comments:

Post a Comment