---
title: "OO事件处理"
author: "e6621887"
date: "2010-12-29T16:32:13Z"
tags: []
categories: ["编程语言"]
slug: "oo"
draft: false
lastmod: "2010-12-29T16:32:13Z"
id: 855001
url: "https://e6621887.iteye.com/blog/855001"
---

class adding definition.  
  public section.  
    class-data num type i.  
    events: return.  
    methods: accumulate.  
endclass.

class adding implementation.  
  method accumulate.  
    data: res type i.  
    num = num + 1.  
    res = num mod 10.  
    if res = 0.  
      raise event return.  
    endif.  
  endmethod.  
endclass.

class handler1 definition.  
  public section.  
    methods: handle\_execute for event return of adding.  
endclass.

class handler1 implementation.  
  method handle\_execute.  
    write:/ 'The present number is:', adding=&gt;num.  
  endmethod.   
endclass.

data: o\_adding type ref to adding,  
      o\_handler type ref to handler1.  
   
start-of-selection.  
  create object:o\_adding, o\_handler.  
  set handler o\_handler-&gt;handle\_execute for all instances."注册  
   
do 50 times.  
  call method o\_adding-&gt;accumulate.  
enddo.