z14-05

*&---------------------------------------------------------------------*
*& Report  Z14_05
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  Z14_05.
*----------------------------------------------------------------------*
*       CLASS c1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS c1 DEFINITION.

    PROTECTED SECTION.
    data: l_num TYPE i.
endclass.

CLASS c2 DEFINITION INHERITING FROM c1.
    PUBLIC SECTION.
    METHODS : set_data IMPORTING p_imp type i,
              get_data exporting p_exp type i.
    ENDCLASS.


*----------------------------------------------------------------------*
*       CLASS c1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
Class c2 implementation.
  method set_data.
    l_num = p_imp.
  ENDMETHOD.                    "set_data

  METHOD get_data.
    p_exp = l_num + 1.
  ENDMETHOD.                    "get_data
endclass.             "c1 IMPLEMENTATION


data: go_cref TYPE REF TO c2.
data: gv_data type i.

START-OF-SELECTION.

  create OBJECT go_cref.
  call method: go_cref->set_data
             EXPORTING p_imp '10'.
*  WRITE:'set_data method:',go_cref->l_num.
  call METHOD: go_cref->get_data
             IMPORTING p_exp = gv_data.
  WRITE:/'get_data method:',gv_data.

 

 

 

posted @ 2014-07-07 06:03  qdxjmei  阅读(129)  评论(0编辑  收藏  举报