Skip to Content
0
Former Member
Jul 20, 2006 at 05:52 PM

Implementing constructor outside class implementation..

41 Views

  • REPORT ZTUSH.

CLASS counter DEFINITION.

PUBLIC SECTION.

METHODS CONSTRUCTOR.

CLASS-METHODS: set IMPORTING value(set_value) TYPE i,

increment,

get EXPORTING value(get_value) TYPE i.

PRIVATE SECTION.

CLASS-DATA count TYPE i.

ENDCLASS.

METHOD CONSTRUCTOR.

WRITE:/ 'I AM CONSTRUCTOR DUDE'.

ENDMETHOD.

CLASS counter IMPLEMENTATION.

METHOD set.

count = set_value.

ENDMETHOD.

ENDCLASS.

DATA cnt TYPE REF TO counter.

START-OF-SELECTION.

CREATE OBJECT cnt.

CALL METHOD counter=>set EXPORTING set_value = number.

I THOUGHT WE CAN DEFINE CONSTRUCTOR METHOD OUTSIDE CLASS IMPLEMENTATION AS IN JAVA. But when I do that I get an error, method can be implemented only withing class. Why?