Inheritance PDF Print E-mail
User Rating: / 0
PoorBest 
ABAP Tutorials - Object Oriented ABAP
Written by Varun Verma   
Tuesday, 09 September 2008 17:24

The concept of inheritance is used to incorporate the properties of an existing class to a new class. The advantage of this feature is that the methods and the attributes of the existing class are automatically taken into the new class and of course with the option to add and enhance new features.

Conceptually - Inheritance can be single inheritance (inherit from exactly one class) or multiple inheritance (inherit from more than one classes). However, unlike C++, ABAP Objecs support only single inheritance. The below diagram illustrates inheritance.

Inheritance

Inheritance is one of the most powerful feature of object oriented programming.
Inheritance is the process of creating new classes, called derived classes or subclasses or child classes from existing classes called base classes or super classes or parent classes. The derived class inherits all the capabilities of the base class but can add embellishments and refinements of its own. The base class is unchanged by this process.

Using Interfaces with Inheritance we can implement multiple inheritance concept in ABAP like in JAVA.

Inheritance can be single level as well as multi level. Inheritance permits code reusability. Once a base class is written and tested, it need not be touched again. Reusing existing code saves time, money and increase a programs reliability.

Syntax for creating child classes:

The syntax is simple (if you are using local classes) : CLASS child_class DEFINITION INHERITING FROM parent_class.

However, if you are using global classes, then in class builder (transaction SE24) go the properties tab and define the super class.

Visibility of attributes:

The public and protected components of the super class are visible in the subclass.
Private section of the super class is not visible in the sub classes.
Private components of the sub class can have same name as the private component of the super class.
Public and Protected components of the sub class can not have the same name as that have been used in super class.

Inheritance Visisbility

Comments
Add New Search
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated ( Tuesday, 09 September 2008 18:13 )
 

Advertisement

 

Google Search

Advertisement