SlideShare a Scribd company logo
1 of 14
Download to read offline
Inheritance : Multiple and
Selective Inheritance
Presented by:
Prativa Marasini
Roll no: 24
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
◆ Inheritancemakes the code reusable.
◆ Reduces redundantcode.
3
Types of inheritance:
◆ Single inheritance
◆ Multiple inheritance
◆ Multilevel inheritance
◆ Selective inheritance
4
1. Single inheritance
◆ Consists of single base class and single derived class.
5
Parent class/base class
Child class/derived class
Fig: single inheritance
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
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
Syntax:
Class base_class1{
Properties;
};
Class base_class2{
Properties;
};
Class derived_class: visibilitymode base_class1,visibilitymode
base_class2{
Properties;
};
8
Some examples:
9
Mammal
Bat
WingedAnimal
Voicemail
MailPhone
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
11
Manager
SalesManager
SalesStaff
Bonus Bonus
• Disallow multiple inheritanceif ambiguity occurs.
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
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
Thank you
14

More Related Content

What's hot

#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance
Hadziq Fabroyir
 

What's hot (20)

Inheritance and Interfaces
Inheritance and InterfacesInheritance and Interfaces
Inheritance and Interfaces
 
EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Inheritance
InheritanceInheritance
Inheritance
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
 
Inheritance
InheritanceInheritance
Inheritance
 
polymorphism
polymorphismpolymorphism
polymorphism
 
Introduction to Inheritance
Introduction to InheritanceIntroduction to Inheritance
Introduction to Inheritance
 
Inheritance in Object Oriented Programming
Inheritance in Object Oriented ProgrammingInheritance in Object Oriented Programming
Inheritance in Object Oriented Programming
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance
 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance and polymorphism
Inheritance and polymorphism   Inheritance and polymorphism
Inheritance and polymorphism
 
inheritance
inheritanceinheritance
inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 

Similar to Inheritance in OODB

E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
classall
 
inheritance-16031525566nbhij56604452.pdf
inheritance-16031525566nbhij56604452.pdfinheritance-16031525566nbhij56604452.pdf
inheritance-16031525566nbhij56604452.pdf
kashafishfaq21
 

Similar to Inheritance in OODB (20)

lecture 6.pdf
lecture 6.pdflecture 6.pdf
lecture 6.pdf
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Final presentation programming
Final presentation programmingFinal presentation programming
Final presentation programming
 
OOP Assign No.03(AP).pdf
OOP Assign No.03(AP).pdfOOP Assign No.03(AP).pdf
OOP Assign No.03(AP).pdf
 
E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
 
inheritance
   inheritance   inheritance
inheritance
 
inheritance-16031525566nbhij56604452.pdf
inheritance-16031525566nbhij56604452.pdfinheritance-16031525566nbhij56604452.pdf
inheritance-16031525566nbhij56604452.pdf
 
Ganesh groups
Ganesh groupsGanesh groups
Ganesh groups
 
Inheritance
Inheritance Inheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
oop database doc for studevsgdy fdsyn hdf
oop database doc for studevsgdy fdsyn hdfoop database doc for studevsgdy fdsyn hdf
oop database doc for studevsgdy fdsyn hdf
 
session 24_Inheritance.ppt
session 24_Inheritance.pptsession 24_Inheritance.ppt
session 24_Inheritance.ppt
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
 
week14 (1).ppt
week14 (1).pptweek14 (1).ppt
week14 (1).ppt
 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In Java
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Unit 2
Unit 2Unit 2
Unit 2
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 

Recently uploaded (20)

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
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
  • 3. ◆ Inheritancemakes the code reusable. ◆ Reduces redundantcode. 3
  • 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
  • 8. Syntax: Class base_class1{ Properties; }; Class base_class2{ Properties; }; Class derived_class: visibilitymode base_class1,visibilitymode base_class2{ Properties; }; 8
  • 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
  • 11. 11 Manager SalesManager SalesStaff Bonus Bonus • Disallow multiple inheritanceif ambiguity occurs.
  • 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