Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Doubt in inheritance tree..!

Former Member
0 Likes
523

hi SAP Guru's !

here is My example :

Class c1 definition.

- - - - - -.

- - - - - -.

- - - - - -.

endclass.

Class c2 definition INHERITING FROM c1.

- - - - - -.

- - - - - -.

- - - - - -.

endclass..

Class c3 definition INHERITING FROM c2.

- - - - - -.

- - - - - -.

- - - - - -.

endclass.

Out of these which one is the root node of inheritance tree ?

and

what is the meaning of this (empty class object )

" the root node on all inheritance trees in ABAP Objects is the predefined EMPTY class OBJECT. "

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
497

Hello Rajesh

The root of all classes in ABAP is the class OBJECT.

Think about an itab in which you want to store instances of any kind of class. What kind of linet_type do you use for your itab?

If, for example, all your collected instances are sub-classes of your c1 class (or c1 itself) then you could use your class C1 as line_type.

If the collected instances do not belong to a single inheritance tree then you must use class OBJECT as line_type.

Example: Have a look at the iterator class CL_SWF_UTL_ITERATOR and its attribute MT_OBJECT_LIST where any kind of instances can be collected.

Further examples of how to use the iterator class or class OBJECT are:

[Accessing the Inacessible - Local Classes within Global Classes|https://wiki.sdn.sap.com/wiki/display/ABAP/AccessingtheInacessible-LocalClasseswithinGlobalClasses]

Regards

Uwe

Hello Rajesh

The root of all classes in ABAP is the class OBJECT.

Think about an itab in which you want to store instances of any kind of class. What kind of linet_type do you use for your itab?

If, for example, all your collected instances are sub-classes of your c1 class (or c1 itself) then you could use your class C1 as line_type.

If the collected instances do not belong to a single inheritance tree then you must use class OBJECT as line_type.

Example: Have a look at the iterator class CL_SWF_UTL_ITERATOR and its attribute MT_OBJECT_LIST where any kind of instances can be collected.

Further examples of how to use the iterator class or class OBJECT are:

[Accessing the Inacessible - Local Classes within Global Classes|https://wiki.sdn.sap.com/wiki/display/ABAP/AccessingtheInacessible-LocalClasseswithinGlobalClasses]

Regards

Uwe

3 REPLIES 3
Read only

Former Member
0 Likes
497

Hi

The root class is: c1.

parent class c1

child class c2

child classc3.

C3 class inherits the properties of c2 and c1 also.

In ABAP like Java, multiple inheritance is not allowed.

This is one of the way to achive multiple inheritence.

If it is helpful rewards points.

Regards

Pratap.M

Read only

matt
Active Contributor
0 Likes
497

>

> In ABAP like Java, multiple inheritance is not allowed.

> This is one of the way to achive multiple inheritence.

>

No. You achieve behaviour like multiple inheritence through interfaces, not subclassing.

Multiple inheritance in C++, for example, is when a class has 2 or more superclasses. Which would be something like Class c3 definition INHERITING FROM c1 and c2. ( When c2 is NOT a subclass of c1 ).

matt

Read only

uwe_schieferstein
Active Contributor
0 Likes
498

Hello Rajesh

The root of all classes in ABAP is the class OBJECT.

Think about an itab in which you want to store instances of any kind of class. What kind of linet_type do you use for your itab?

If, for example, all your collected instances are sub-classes of your c1 class (or c1 itself) then you could use your class C1 as line_type.

If the collected instances do not belong to a single inheritance tree then you must use class OBJECT as line_type.

Example: Have a look at the iterator class CL_SWF_UTL_ITERATOR and its attribute MT_OBJECT_LIST where any kind of instances can be collected.

Further examples of how to use the iterator class or class OBJECT are:

[Accessing the Inacessible - Local Classes within Global Classes|https://wiki.sdn.sap.com/wiki/display/ABAP/AccessingtheInacessible-LocalClasseswithinGlobalClasses]

Regards

Uwe