2015 Feb 25 11:11 AM
can anyone tell me what the statement in bold here is?
CREATE OBJECT obj1->o2.
what does this create object implying an attribute of class c1? create object will just create and instance of class right? what exactly is this sentence?
CLASS c1 DEFINITION.
PUBLIC SECTION.
DATA o2 TYPE REF TO c2.
ENDCLASS.
CLASS c2 DEFINITION.
PUBLIC SECTION.
DATA : num TYPE i VALUE 5.
ENDCLASS.
START-OF-SELECTION.
DATA : obj1 TYPE REF TO c1.
CREATE OBJECT obj1.
CREATE OBJECT obj1->o2.
WRITE : /5 obj1->o2->num.
Thanks & Regards
2015 Feb 25 11:27 AM
Hi Anjali,
In your above code CREATE OBJECT obj1->o2 is used for creating object o2 for class c2.
As because you have declared the object O2 inside the class C1 you can't directly access to the object O2 outside the class.
CLASS c1 DEFINITION.
PUBLIC SECTION.
DATA o2 TYPE REF TO c2.
ENDCLASS
You need an Instance of the class C1 ie obj1. Through the instance or object you can create the object of class c2 or object O2.
Regards,
Swaroop
2015 Feb 25 11:27 AM
Hi Anjali,
In your above code CREATE OBJECT obj1->o2 is used for creating object o2 for class c2.
As because you have declared the object O2 inside the class C1 you can't directly access to the object O2 outside the class.
CLASS c1 DEFINITION.
PUBLIC SECTION.
DATA o2 TYPE REF TO c2.
ENDCLASS
You need an Instance of the class C1 ie obj1. Through the instance or object you can create the object of class c2 or object O2.
Regards,
Swaroop
2015 Feb 25 11:29 AM
2015 Feb 25 11:39 AM
Hi,
Seems like you creating an inner object (O2) (and this is working) .
I put c2 before c1 .
Regards .