标签:public methods 派生类 subclass value write nbsp class 基类
*----------------------------------------------------------------------*
* CLASS superclass DEFINITION 定义基类
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS superclass DEFINITION.
PUBLIC SECTION.
DATA:para(30) TYPE c VALUE ‘The Super method‘.
METHODS write_first.
ENDCLASS. "superclass DEFINITION
*----------------------------------------------------------------------*
* CLASS subclass DEFINITION 定义派生类
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS subclass DEFINITION INHERITING FROM superclass.
PUBLIC SECTION.
METHODS write_first REDEFINITION. "定义重载方法
METHODS write_second.
ENDCLASS. "subclass DEFINITION
*----------------------------------------------------------------------*
* CLASS superclass IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS superclass IMPLEMENTATION.
METHOD write_first.
WRITE: / para.
ENDMETHOD. "write_first
ENDCLASS. "superclass IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS subclass IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS subclass IMPLEMENTATION.
METHOD write_first.
CALL METHOD super->write_first."调用基类的方法
ENDMETHOD. "write_first
METHOD write_second.
para = ‘The Redefinition method‘.
CALL METHOD me->write_first."调用本身类的方法
ENDMETHOD. "write_second
ENDCLASS. "subclass IMPLEMENTATION
DATA:inher_obj TYPE REF TO subclass.
START-OF-SELECTION.
CREATE OBJECT inher_obj.
CALL METHOD:inher_obj->write_first,"调用派生类的重载方法
inher_obj->write_second.
标签:public methods 派生类 subclass value write nbsp class 基类
原文地址:http://www.cnblogs.com/zxiu/p/7562437.html