*----------------------------------------------------------------------*
* CLASS person DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS person DEFINITION.
ENDCLASS. "person DEFINITION
*----------------------------------------------------------------------*
* CLASS stud DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS stud DEFINITION INHERITING FROM person.
ENDCLASS. "stud DEFINITION
START-OF-SELECTION.
DATA p TYPE REF TO person.
DATA s TYPE REF TO stud.
CREATE OBJECT s.
p = s."向上自动转型
"拿开注视运行时抛异常,因此p此时指向的对象不是Student,而是person之所以能强转的前提是p指向的是student
"CREATE OBJECT p.
s ?= p."向下强转型