Application Development 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: 

mulitple inheritqnce ?

Former Member
0 Kudos

give one sample code for multiple inheriatance in abap objects.

1 ACCEPTED SOLUTION

0 Kudos

Hi,

MULTIPLE INHERITANCE is not possible in ABAP objects.

This behaviour can be simulated using INTERFACES.

Since one class can implement more than one interface this behaviour is simulated.

You can use reference of Different Interfaces Talking to Object of one class which is implementing all these interfaces.

Regards,

Sesh

3 REPLIES 3

0 Kudos

Hi,

MULTIPLE INHERITANCE is not possible in ABAP objects.

This behaviour can be simulated using INTERFACES.

Since one class can implement more than one interface this behaviour is simulated.

You can use reference of Different Interfaces Talking to Object of one class which is implementing all these interfaces.

Regards,

Sesh

Former Member
0 Kudos

Hi

multiple inheritence is not possible in abap objects

example for inheritance..

REPORT demo_inheritance.

CLASS counter DEFINITION.

PUBLIC SECTION.

METHODS: set IMPORTING value(set_value) TYPE i,

increment,

get EXPORTING value(get_value) TYPE i.

PROTECTED SECTION.

DATA count TYPE i.

ENDCLASS.

CLASS counter IMPLEMENTATION.

METHOD set.

count = set_value.

ENDMETHOD.

METHOD increment.

ADD 1 TO count.

ENDMETHOD.

METHOD get.

get_value = count.

ENDMETHOD.

ENDCLASS.

CLASS counter_ten DEFINITION INHERITING FROM counter.

PUBLIC SECTION.

METHODS increment REDEFINITION.

DATA count_ten(1) TYPE c.

ENDCLASS.

CLASS counter_ten IMPLEMENTATION.

METHOD increment.

DATA modulo TYPE i.

CALL METHOD super->increment.

WRITE / count.

modulo = count MOD 10.

IF modulo = 0.

count_ten = count_ten + 1.

WRITE count_ten.

ENDIF.

ENDMETHOD.

ENDCLASS.

DATA: count TYPE REF TO counter,

number TYPE i VALUE 5.

START-OF-SELECTION.

CREATE OBJECT count TYPE counter_ten.

CALL METHOD count->set EXPORTING set_value = number.

DO 20 TIMES.

CALL METHOD count->increment.

ENDDO.

reward points to all helpful answers

kiran.M

GrahamRobbo
Active Contributor
0 Kudos

IMHO Multiple inheritance is a bad thing.

The biggest issue is what is known as the Diamond Problem.

For more info look at http://www.javaworld.com/javaworld/javaqa/2001-03/02-qa-0323-diamond.html

Cheers

Graham