*类的定义与类的实现是分开的
class myClass definition.
*定义了3个PUBLIC的方法,分别是"set","increment","get",其中"set"各包含一个i类型的输入参数,"get"返回一个i类型的值.
public section.
    METHODS: set IMPORTING value(set_value) TYPE i,
             increment,
             get EXPORTING value(get_value) TYPE i.
private section.
  data count type i.
endClass.

class myClass implementation.
  METHOD set.
    count = set_value.
  ENDMETHOD.
  METHOD increment.
    ADD 1 TO count.
  ENDMETHOD.
  METHOD get.
    get_value = count.
  ENDMETHOD.
endClass.


*定义一个类
data instance type REF to myClass.
START-OF-SELECTION.
*实例化该类
CREATE OBJECT instance.
posted on 2008-12-11 11:53  yxbsmx  阅读(283)  评论(0编辑  收藏  举报