I am writing below a small code which says Deffered definition of class.
Can anyone tell me what is the main objective of going for deffered defintion .
1.6 Deferred Definition of a Class
Theme This program will demonstrate how one can refer to a class without defining the class before that point. But, the class has to be defined later on.
Program description In this program , class C1 has an interface reference O2 declared with reference to class C2. But, before that, class C2 is not defined. It is defined later with a single public attribute , NUM .
This demonstrates the theme.
In the main section of the program, object : OBJ1 is created from class C1.
Then, an object is created from the reference variable O2 in class C1. Finally, the attribute num of that object is displayed.
Dump report ysubdel1.
CLASS C2 DEFINITION DEFERRED.
CLASS C1 DEFINITION.
DATA O2 TYPE REF TO C2.
CLASS C2 DEFINITION.
data : num type i value 5.
data : obj1 type ref to C1.
CREATE OBJECT obj1.
create object obj1->o2.
write:/5 obj1->o2->num .