Micro-Scholarship, What it is, How can it help me.pdf
Inheritance in OODB
1. Inheritance : Multiple and
Selective Inheritance
Presented by:
Prativa Marasini
Roll no: 24
2. Inheritance
◆ It is the capability of one class to inherit or acquire properties
from anotherclass.
◆ A class that inherits or derives attributesfrom anotherclass is
known as derived class.
◆ A class from which the attributesare derived is known as base
class.
◆ The base class is actuallya superclass and the derived class is a
subclass.
◆ So in simple terms, inheritancemeans deriving qualityand
characteristics from parent or ancestors.
2
4. Types of inheritance:
◆ Single inheritance
◆ Multiple inheritance
◆ Multilevel inheritance
◆ Selective inheritance
4
5. 1. Single inheritance
◆ Consists of single base class and single derived class.
5
Parent class/base class
Child class/derived class
Fig: single inheritance
6. 2. Multiple inheritance
◆ It is the feature of object oriented programming in which an
object or class inherit characteristicsand features from more than
one parent class or object.
Fig: Multipleinheritance
6
7. Contd..
◆ It allows us to combine the features of several existing classes.
◆ Eg: A child can inherit the characterof his both father and
mother.
◆ It differs from single inheritancepropertywhich allows an object
or class to inherit from one specific class or object.
7
10. Ambiguity in multiple inheritance
◆ The conflict arises in multiple inheritancewhen the super classes
containsthe same attributesor method.
Solution:
• Includeboth attributes/methodand use the name of super class as
qualifier.
e.g: If bonusis attributeof both Manger and SalesStaff the subclass
SalesManager can inherit bonusfrom both, and qualify bonusin
SalesManager as either Manager.Bonus or SalesStaff.Bonus
10
12. 3. Multilevel inheritance
In it, a class inherits from a derived class making that derived class a
base class for a new class.
■ As per shown in diagram, Class C is the
subclass of Class B and Class B is the
subclass of Class A.
Fig: Multilevel inheritance12
13. 4. Selective Inheritance
◆ It allows a subclass to inherit only limited number of properties
from the superclass.
◆ EXCEPT clause may be used to list a function in a superclass that
are not to be inherited by the subclass.
◆ Eg:
◆ Selective inheritanceis not typically provided in object oriented
databasesystems.
13
Person
Blind personSeeing person