REPORT Z017_007 .
* Class Declarations
CLASS vehicle DEFINITION INHERITING FROM object.
PUBLIC SECTION.
METHODS: create.
PROTECTED SECTION.
DATA speed TYPE i value '90'.
ENDCLASS.
CLASS plane DEFINITION INHERITING FROM vehicle.
PUBLIC SECTION.
METHODS: fly.
PROTECTED SECTION.
DATA altitude TYPE i.
ENDCLASS.
* Class Implementations
CLASS vehicle IMPLEMENTATION.
METHOD create.
speed = speed + 10.
WRITE: / 'air777 is from pony????'.
ENDMETHOD.
ENDCLASS.
CLASS plane IMPLEMENTATION.
METHOD fly.
speed = speed + 1000.
ENDMETHOD.
ENDCLASS.
* Global Data
DATA: pony TYPE REF TO vehicle,
air777 TYPE REF TO vehicle.
* Classical Processing Blocks
START-OF-SELECTION.
CREATE OBJECT: pony.
air777 ?= pony.
* move pony to excel.
* CALL METHOD: air777->fly.
CALL METHOD: air777->create.
* CALL METHOD: air777->create.
* Class Declarations
CLASS vehicle DEFINITION INHERITING FROM object.
PUBLIC SECTION.
METHODS: create.
PROTECTED SECTION.
DATA speed TYPE i value '90'.
ENDCLASS.
CLASS plane DEFINITION INHERITING FROM vehicle.
PUBLIC SECTION.
METHODS: fly.
PROTECTED SECTION.
DATA altitude TYPE i.
ENDCLASS.
* Class Implementations
CLASS vehicle IMPLEMENTATION.
METHOD create.
speed = speed + 10.
WRITE: / 'air777 is from pony????'.
ENDMETHOD.
ENDCLASS.
CLASS plane IMPLEMENTATION.
METHOD fly.
speed = speed + 1000.
ENDMETHOD.
ENDCLASS.
* Global Data
DATA: pony TYPE REF TO vehicle,
air777 TYPE REF TO vehicle.
* Classical Processing Blocks
START-OF-SELECTION.
CREATE OBJECT: pony.
air777 ?= pony.
* move pony to excel.
* CALL METHOD: air777->fly.
CALL METHOD: air777->create.
* CALL METHOD: air777->create.
댓글 3
-
가로수
2011.11.02 23:47
-
겸이82
2012.07.24 19:44
air777이 PLANE을 참조해야 예제의 의미가 맞는거 같습니다.
저도 이상해서 이렇게 찾아오게 되었네요~
-
나비효과
2013.10.25 16:49
air777를 PLANE으로 바꾸면. 위처럼 하면 에러가 발생하던데요.
굳이 air777를 PLANE으로 바꾸려면,
pony TYPE REF TO vehicle,
air777 TYPE REF TO plane."vehicle
pony ?= air777.
CALL METHOD: pony->create.이렇게 하면 에러가 안나오긴 한데. 이걸 CASTING의 효과를 보기 위한게 맞는지 궁금하네요.
pony->fly 쓸수 있어야 할것 같은데요.
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
71 | Z17_ZSFLIGHT | sapjoy | 2007.02.27 | 2413 |
70 | REPORT Z17_028 | sapjoy | 2007.02.26 | 2940 |
69 | REPORT Z09_013 | sapjoy | 2007.02.24 | 2243 |
68 | REPORT Z17_020. [2] | sapjoy | 2007.02.23 | 2187 |
67 | REPORT z17_025 | sapjoy | 2007.02.23 | 2204 |
66 | REPORT Z17_020 | sapjoy | 2007.02.23 | 2172 |
65 | REPORT Z17_000. | sapjoy | 2007.02.22 | 2419 |
64 | REPORT Z17_022 | sapjoy | 2007.02.22 | 2315 |
63 | REPORT Z17_017 . | sapjoy | 2007.02.15 | 2181 |
62 | REPORT Z17_016 . | sapjoy | 2007.02.14 | 2162 |
61 | REPORT Z17_015 | sapjoy | 2007.02.13 | 2282 |
60 | REPORT Z17_012 | sapjoy | 2007.02.13 | 2305 |
59 | INCLUDE Z17_011_CLASS | sapjoy | 2007.02.12 | 2489 |
58 | REPORT Z17_011 | sapjoy | 2007.02.12 | 2287 |
» | REPORT Z017_007 [3] | sapjoy | 2007.02.12 | 2353 |
56 | REPORT Z17_006 | sapjoy | 2007.02.12 | 2209 |
55 | REPORT Z17_005 | sapjoy | 2007.02.12 | 2174 |
54 | REPORT Z17_003 | sapjoy | 2007.02.09 | 2347 |
53 | REPORT Z17_002 | sapjoy | 2007.02.08 | 2138 |
52 | REPORT Z17_001. | sapjoy | 2007.02.07 | 2147 |
CASTING 정확하게 왜서 쓰는지 ? 어떤 경우에 사용하는지 잘 이해가 안되네요...
그리고 위에 소스 이분에서 PONY AIR777 이 둘다 VEHICLE를 참조하고 있다면
굳이 CASTING 할필요가 있는지요 .단지 CREATE OBJECT AIR777 이구문을 줄이기 위해서인가요 ?
DATA: pony TYPE REF TO vehicle,
air777 TYPE REF TO vehicle.
이와같이 수정해야만 CASTING 효과를 볼수있는게 아닌가 싶네요
DATA: pony TYPE REF TO vehicle,
air777 TYPE REF TO PLANE.
간단한 설명 부탁드립니다.