REPORT z14_08.
CLASS vehicle DEFINITION INHERITING FROM object.
PUBLIC SECTION.
METHODS: create,
drive.
PROTECTED SECTION.
DATA speed TYPE i VALUE '100'.
ENDCLASS. "vehicle DEFINITION
CLASS plane DEFINITION INHERITING FROM vehicle.
PUBLIC SECTION.
METHODS: fly.
ENDCLASS. "plane DEFINITION
* Class IMPLEMENTATION
CLASS vehicle IMPLEMENTATION.
METHOD create.
ENDMETHOD. "vehicle
METHOD drive.
speed = speed + 100.
WRITE : 'Driving is possible, ', 'Current:', speed.
ENDMETHOD. "vehicle
ENDCLASS. "vehicle IMPLEMENTATION
CLASS plane IMPLEMENTATION.
METHOD fly.
speed = speed + 1000.
ENDMETHOD.
ENDCLASS. "plane IMPLEMENTATION
DATA : car TYPE REF TO vehicle,
air TYPE REF TO plane.
START-OF-SELECTION.
CREATE OBJECT: car.
air ?= car.
CALL METHOD: air->drive.
CALL METHOD: air->fly.
댓글 3
-
쿨조운
2013.11.22 20:09
-
리얼오버
2024.03.01 17:50
소스코드 수정본
REPORT z14_08.
CLASS vehicle DEFINITION INHERITING FROM object.
PUBLIC SECTION.
METHODS: create,
drive.
PROTECTED SECTION.
DATA speed TYPE i VALUE '100'.
ENDCLASS. "vehicle DEFINITION
CLASS plane DEFINITION INHERITING FROM vehicle.
PUBLIC SECTION.
METHODS: fly.
ENDCLASS. "plane DEFINITION
* Class IMPLEMENTATION
CLASS vehicle IMPLEMENTATION.
METHOD create.
ENDMETHOD. "vehicle
METHOD drive.
speed = speed + 100.
WRITE : 'Driving is possible, ', 'Current:', speed.
ENDMETHOD. "vehicle
ENDCLASS. "vehicle IMPLEMENTATION
CLASS plane IMPLEMENTATION.
METHOD fly.
speed = speed + 1000.
ENDMETHOD.
ENDCLASS. "plane IMPLEMENTATION
DATA : car TYPE REF TO vehicle,
air TYPE REF TO plane.
START-OF-SELECTION.
CREATE OBJECT: car,
air TYPE plane. " 비행기 클래스의 인스턴스 생성
* air ?= car.
CALL METHOD: car->create. " 차량 생성
CALL METHOD: air->drive.
CALL METHOD: air->fly. -
오로나민
2024.06.28 21:27
casting 주석 풀면 에러나네요. 수정 부탁드려요
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
591 | REPORT Z14_20. | sapjoy | 2012.08.02 | 929 |
590 | REPORT z14_19. | sapjoy | 2012.08.02 | 975 |
589 | REPORT Z14_18. | sapjoy | 2012.08.02 | 906 |
588 | REPORT z14_17. | sapjoy | 2012.08.02 | 1030 |
587 | REPORT z14_16. [1] | sapjoy | 2012.08.02 | 912 |
586 | REPORT z14_15. | sapjoy | 2012.08.02 | 1022 |
585 | REPORT z14_14. | sapjoy | 2012.08.02 | 1020 |
584 | REPORT z14_13. | sapjoy | 2012.08.02 | 804 |
583 | REPORT z14_12. | sapjoy | 2012.08.02 | 857 |
582 | REPORT z14_11. | sapjoy | 2012.08.02 | 841 |
581 | REPORT z14_10. | sapjoy | 2012.08.02 | 852 |
580 | REPORT z14_09. | sapjoy | 2012.08.02 | 804 |
» | REPORT z14_08. [3] | sapjoy | 2012.08.02 | 1023 |
578 | REPORT z14_07. | sapjoy | 2012.08.02 | 819 |
577 | REPORT z14_06. [1] | sapjoy | 2012.08.02 | 1011 |
576 | REPORT z14_05. | sapjoy | 2012.08.02 | 862 |
575 | REPORT z14_04. | sapjoy | 2012.08.02 | 936 |
574 | REPORT z14_03. | sapjoy | 2012.08.02 | 874 |
573 | REPORT Z14_02. | sapjoy | 2012.08.02 | 847 |
572 | REPORT Z14_01. | sapjoy | 2012.08.02 | 915 |
에러가 나네요 casting에러요 air 객체와 car 객체를 casting 했는데 오류 납니다.