Skip to Content
0
Former Member
Aug 31, 2007 at 11:59 AM

Regarding Deffered definition

21 Views

Hi,

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.

<code>

CLASS C2 DEFINITION DEFERRED.

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 .

</code>

Thanks,

satya