SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
MULTIPLE INHERITANCE
Muhammad Adil Raja
Roaming Researchers, Inc.
cbna
April 20, 2015
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
OUTLINE I
INTRODUCTION
MULTIPLE INHERITANCE
NAME AMBIGUITY
COMMON ANCESTORS
INNER CLASSES
SUMMARY
REFERENCES
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INTRODUCTION
• We will investigate some of the problems that can arize
when a language allows a child class to have multiple
parents.
• Name ambiguity.
• Impact on substitution.
• The Problem of Common Ancestors.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
THE IDEALIZATION OF IS-A RELATIONSHIP
MESSAGE SYNTAX
• In one sense, the process of inheritance is a form of
categorization. A TextWindow is a type of Window, so
class TextWindow inherits from class Window.
• But in the real world, most objects can be categorized in a
variety of ways.
• The author of the textbook is:
• North American.
• Male.
• Professor.
• Parent.
• None of these are proper subsets of the other, and we
cannot make a single rooted inheritance hierarchy out of
them.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INHERITANCE AS COMBINATION
• Instead, real world objects are combinations of features
from different classification schemes, each category giving
some new insight into the whole:
• Author is North American, and
• Author is Male, and
• Author is a Professor, and
• Author is a Parent.
• Note that we have not lost the is-a relationship; it still
applies in each case.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
CS EXAMPLE – COMPLEX NUMBERS
Two abstract classifications
• Magnitude – things that can be compared to each other.
• Number – things that can perform arithmetic.
Three specific classes
• Integer – comparable and arithmetic.
• Char – comparable but not arithmetic.
• Complex – arithmetic but not comparable.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
POSSIBLE SOLUTIONS
1. Make Number subclass of Magnitude, but redefine
comparison operators in class complex to give error
message if used. (subclassing for limitation)
2. Don’t use inheritance at all – redefine all operators in all
classes. (flattening the inheritance tree).
3. Use part inheritance, but simulate others – use Number,
but have each number implement all relational operators.
4. Make Number and Magnitude independent, and have
Integer inherit from both. (multiple inheritance).
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INHERITANCE AS A FORM OF COMBINATION
FIGURE : Inheritance.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
ANOTHER EXAMPLE – WALKING MENUS
• A Menu is a structure charged with displaying itself when
selected by the user.
• A
• Menu maintains a collection of MenuItems.
• Each MenuItem knows how to respond when selected.
• A cascading menu is both a MenuItem and a Menu.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
PROBLEM WITH MI – NAME AMBUITY
• What happens when same name is used in both parent
classes.
• A
• CardDeck knows how to draw a Card.
• A GraphicalItem knows how to draw an image on a
screen.
• A GraphicalCardDeck should be able to draw. which?
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
ONE SOLUTION – REDEFINITION
One solution is to redefine one or the other operation in the
child class.
REDEFINITION
class GraphicalCardDeck : public CardDeck , public GraphicalObject {
public :
virtual void draw ( ) { return CardDeck : : draw ( ) ; }
virtual void paint ( ) { GraphicalObject : : draw ( ) ; }
}
GraphicalCardDeck gcd ;
gcd−>draw ( ) ; / / selects CardDeck draw
gcd−>paint ( ) ; / / selects GraphicalObject draw
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
PROBLEM WITH REDEFINITION SOLUTION
• The redefinition solution is not without cost, however.
• Now what happens when we run up against the principle of
substitution?
REDEFINITION
GraphicalObject ∗ g = new GraphicalCardDeck ( ) ;
g−>draw ( ) ; / / opps , doing wrong method !
This problem can be mitigated, but the solution is complex and
not perfect.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
OTHER APPROACHES TO NAME AMBIGUITY
• Other languages use different approaches to solving the
problem of ambiguous names.
• Eiffel uses the ability to rename features from the parent
class.
• A polymorphic variable accessing through the parents
name will access the renamed feature in the child.
• CLOS and Python resolve ambiguous names by the order
in which the parent classes are listed.
• The first occurrence of the name found in a systematic
search is the one selected.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
MULTIPLE INHERITANCE OF INTERFACES
• Multiple inheritance of interfaces does not present the
same problem of name ambiguity as does multiple
inheritance of classes.
• Either the ambiguous methods in the parent classes have
different type signatures, in which case there is no
problem, or
• The ambiguous methods in the parent classes have the
same signature. Still no problem, since what is inherited is
only a specification, not an implementation.
• This is why Java permits multiple inheritance of interfaces,
not of classes. Nevertheless, C# does not permit the same
method name to be inherited from two parent interfaces.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INHERITANCE FROM COMMON ANCESTORS
• Another problem with MI occurs when parent classes have
a common root ancestor.
• Does the new object have one or two instances of the
ancestor?
FIGURE : Inheritance from common ancestors.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
DATA FIELD IN COMMON ANCESTOR
• Imagine that the common ancestor declares a data
member. Should the child class have one copy of this data
field, or two?
• Both answers can be justified with examples.
• C++ gets around this by introducing the idea of a virtual
parent class.
• If your parent is virtual there is one copy, and if not there is
two.
• Not a perfect solution, and makes the language
complicated.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INNER CLASSES
• The ability to next classes in C++ and Java provides a
mechanism that is nearly equivalent to multiple
inheritance, without the semantic problems.
INNER CLASS
class Child extends ParentOne {
. . .
class InnerChild extends ParentTwo {
. . .
/ / can access both parents
}
}
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
SUMMARY
• In this chapter we have explored some of the problems that
arise of the concept of multiple inheritance.
• Name ambiguity.
• Impact on substitution.
• The Problem of Common Ancestors.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
REFERENCES
• Images and content for developing these slides have been
taken from the follwoing book with the permission of the
author.
• An Introduction to Object Oriented Programming, Timothy
Budd.
• This presentation is developed using Beamer:
• Singapore, wolverine.

Contenu connexe

Tendances

Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oopsHirra Sultan
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaRahulAnanda1
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classesShreyans Pathak
 
Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++Janki Shah
 
OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++Aabha Tiwari
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in javaAhsan Raja
 
EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++Nikunj Patel
 
Inheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan PasrichaInheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan PasrichaMananPasricha
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++Sujan Mia
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In JavaSpotle.ai
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming languageMd.Al-imran Roton
 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphismkiran Patel
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
Inheritance in Object Oriented Programming
Inheritance in Object Oriented ProgrammingInheritance in Object Oriented Programming
Inheritance in Object Oriented ProgrammingAshita Agrawal
 

Tendances (20)

Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
 
Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
 
OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++
 
Java access modifiers
Java access modifiersJava access modifiers
Java access modifiers
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
 
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++ by Manan Pasricha
Inheritance in c++ by Manan PasrichaInheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan Pasricha
 
Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In Java
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphism
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Inheritance in Object Oriented Programming
Inheritance in Object Oriented ProgrammingInheritance in Object Oriented Programming
Inheritance in Object Oriented Programming
 

En vedette

En vedette (19)

Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
 
Protols used in bluetooth
Protols used in bluetoothProtols used in bluetooth
Protols used in bluetooth
 
Introduction to Embedded System
Introduction to Embedded SystemIntroduction to Embedded System
Introduction to Embedded System
 
Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...
 
Arm processor
Arm processorArm processor
Arm processor
 
Arm developement
Arm developementArm developement
Arm developement
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
 
SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
 
Embedded C
Embedded CEmbedded C
Embedded C
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Iot
IotIot
Iot
 

Similaire à Problems of Multiple Inheritance in Object Oriented Programming

Polymorphism
PolymorphismPolymorphism
PolymorphismNuha Noor
 
Inheritance and Substitution
Inheritance and SubstitutionInheritance and Substitution
Inheritance and Substitutionadil raja
 
Multiple inheritance in java3 (1).pptx
Multiple inheritance in java3 (1).pptxMultiple inheritance in java3 (1).pptx
Multiple inheritance in java3 (1).pptxRkGupta83
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 
How would you implement multiple inheritance in java
How would you implement multiple inheritance in javaHow would you implement multiple inheritance in java
How would you implement multiple inheritance in javaTyagi2636
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS ConceptRicha Gupta
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentalsAnsgarMary
 
2CPP07 - Inheritance
2CPP07 - Inheritance2CPP07 - Inheritance
2CPP07 - InheritanceMichael Heron
 
Multiple inheritance possible in Java
Multiple inheritance possible in JavaMultiple inheritance possible in Java
Multiple inheritance possible in JavaKurapati Vishwak
 
Multiple inheritance
Multiple inheritanceMultiple inheritance
Multiple inheritancezindadili
 
OO relationships between classes
OO relationships between classesOO relationships between classes
OO relationships between classesSujit Kumar
 

Similaire à Problems of Multiple Inheritance in Object Oriented Programming (20)

Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Inheritance and Substitution
Inheritance and SubstitutionInheritance and Substitution
Inheritance and Substitution
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
 
Unit 3
Unit 3Unit 3
Unit 3
 
Multiple inheritance in java3 (1).pptx
Multiple inheritance in java3 (1).pptxMultiple inheritance in java3 (1).pptx
Multiple inheritance in java3 (1).pptx
 
INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4
 
SAD04 - Inheritance
SAD04 - InheritanceSAD04 - Inheritance
SAD04 - Inheritance
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
Java_notes.ppt
Java_notes.pptJava_notes.ppt
Java_notes.ppt
 
How would you implement multiple inheritance in java
How would you implement multiple inheritance in javaHow would you implement multiple inheritance in java
How would you implement multiple inheritance in java
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
 
Concepts of oop1
Concepts of oop1Concepts of oop1
Concepts of oop1
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
 
2CPP07 - Inheritance
2CPP07 - Inheritance2CPP07 - Inheritance
2CPP07 - Inheritance
 
Multiple inheritance possible in Java
Multiple inheritance possible in JavaMultiple inheritance possible in Java
Multiple inheritance possible in Java
 
Multiple inheritance
Multiple inheritanceMultiple inheritance
Multiple inheritance
 
Lo15
Lo15Lo15
Lo15
 
OO relationships between classes
OO relationships between classesOO relationships between classes
OO relationships between classes
 
Inheritance
InheritanceInheritance
Inheritance
 
04 inheritance
04 inheritance04 inheritance
04 inheritance
 

Plus de adil raja

A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specificationadil raja
 
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial VehiclesNUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehiclesadil raja
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystifiedadil raja
 
On Research (And Development)
On Research (And Development)On Research (And Development)
On Research (And Development)adil raja
 
Simulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge ResearchSimulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge Researchadil raja
 
The Knock Knock Protocol
The Knock Knock ProtocolThe Knock Knock Protocol
The Knock Knock Protocoladil raja
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Socketsadil raja
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Executionadil raja
 
CMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor PakistanCMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor Pakistanadil raja
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousingadil raja
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...adil raja
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...adil raja
 
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPReal-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPadil raja
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specificationsadil raja
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...adil raja
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...adil raja
 

Plus de adil raja (20)

ANNs.pdf
ANNs.pdfANNs.pdf
ANNs.pdf
 
A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specification
 
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial VehiclesNUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystified
 
On Research (And Development)
On Research (And Development)On Research (And Development)
On Research (And Development)
 
Simulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge ResearchSimulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge Research
 
The Knock Knock Protocol
The Knock Knock ProtocolThe Knock Knock Protocol
The Knock Knock Protocol
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Sockets
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Execution
 
Thesis
ThesisThesis
Thesis
 
CMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor PakistanCMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor Pakistan
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPReal-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
 
VoIP
VoIPVoIP
VoIP
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specifications
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 
ULMAN-GUI
ULMAN-GUIULMAN-GUI
ULMAN-GUI
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 

Dernier

Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 

Dernier (20)

Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 

Problems of Multiple Inheritance in Object Oriented Programming

  • 1. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References MULTIPLE INHERITANCE Muhammad Adil Raja Roaming Researchers, Inc. cbna April 20, 2015
  • 2. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References OUTLINE I INTRODUCTION MULTIPLE INHERITANCE NAME AMBIGUITY COMMON ANCESTORS INNER CLASSES SUMMARY REFERENCES
  • 3. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INTRODUCTION • We will investigate some of the problems that can arize when a language allows a child class to have multiple parents. • Name ambiguity. • Impact on substitution. • The Problem of Common Ancestors.
  • 4. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References THE IDEALIZATION OF IS-A RELATIONSHIP MESSAGE SYNTAX • In one sense, the process of inheritance is a form of categorization. A TextWindow is a type of Window, so class TextWindow inherits from class Window. • But in the real world, most objects can be categorized in a variety of ways. • The author of the textbook is: • North American. • Male. • Professor. • Parent. • None of these are proper subsets of the other, and we cannot make a single rooted inheritance hierarchy out of them.
  • 5. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INHERITANCE AS COMBINATION • Instead, real world objects are combinations of features from different classification schemes, each category giving some new insight into the whole: • Author is North American, and • Author is Male, and • Author is a Professor, and • Author is a Parent. • Note that we have not lost the is-a relationship; it still applies in each case.
  • 6. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References CS EXAMPLE – COMPLEX NUMBERS Two abstract classifications • Magnitude – things that can be compared to each other. • Number – things that can perform arithmetic. Three specific classes • Integer – comparable and arithmetic. • Char – comparable but not arithmetic. • Complex – arithmetic but not comparable.
  • 7. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References POSSIBLE SOLUTIONS 1. Make Number subclass of Magnitude, but redefine comparison operators in class complex to give error message if used. (subclassing for limitation) 2. Don’t use inheritance at all – redefine all operators in all classes. (flattening the inheritance tree). 3. Use part inheritance, but simulate others – use Number, but have each number implement all relational operators. 4. Make Number and Magnitude independent, and have Integer inherit from both. (multiple inheritance).
  • 8. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INHERITANCE AS A FORM OF COMBINATION FIGURE : Inheritance.
  • 9. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References ANOTHER EXAMPLE – WALKING MENUS • A Menu is a structure charged with displaying itself when selected by the user. • A • Menu maintains a collection of MenuItems. • Each MenuItem knows how to respond when selected. • A cascading menu is both a MenuItem and a Menu.
  • 10. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References PROBLEM WITH MI – NAME AMBUITY • What happens when same name is used in both parent classes. • A • CardDeck knows how to draw a Card. • A GraphicalItem knows how to draw an image on a screen. • A GraphicalCardDeck should be able to draw. which?
  • 11. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References ONE SOLUTION – REDEFINITION One solution is to redefine one or the other operation in the child class. REDEFINITION class GraphicalCardDeck : public CardDeck , public GraphicalObject { public : virtual void draw ( ) { return CardDeck : : draw ( ) ; } virtual void paint ( ) { GraphicalObject : : draw ( ) ; } } GraphicalCardDeck gcd ; gcd−>draw ( ) ; / / selects CardDeck draw gcd−>paint ( ) ; / / selects GraphicalObject draw
  • 12. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References PROBLEM WITH REDEFINITION SOLUTION • The redefinition solution is not without cost, however. • Now what happens when we run up against the principle of substitution? REDEFINITION GraphicalObject ∗ g = new GraphicalCardDeck ( ) ; g−>draw ( ) ; / / opps , doing wrong method ! This problem can be mitigated, but the solution is complex and not perfect.
  • 13. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References OTHER APPROACHES TO NAME AMBIGUITY • Other languages use different approaches to solving the problem of ambiguous names. • Eiffel uses the ability to rename features from the parent class. • A polymorphic variable accessing through the parents name will access the renamed feature in the child. • CLOS and Python resolve ambiguous names by the order in which the parent classes are listed. • The first occurrence of the name found in a systematic search is the one selected.
  • 14. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References MULTIPLE INHERITANCE OF INTERFACES • Multiple inheritance of interfaces does not present the same problem of name ambiguity as does multiple inheritance of classes. • Either the ambiguous methods in the parent classes have different type signatures, in which case there is no problem, or • The ambiguous methods in the parent classes have the same signature. Still no problem, since what is inherited is only a specification, not an implementation. • This is why Java permits multiple inheritance of interfaces, not of classes. Nevertheless, C# does not permit the same method name to be inherited from two parent interfaces.
  • 15. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INHERITANCE FROM COMMON ANCESTORS • Another problem with MI occurs when parent classes have a common root ancestor. • Does the new object have one or two instances of the ancestor? FIGURE : Inheritance from common ancestors.
  • 16. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References DATA FIELD IN COMMON ANCESTOR • Imagine that the common ancestor declares a data member. Should the child class have one copy of this data field, or two? • Both answers can be justified with examples. • C++ gets around this by introducing the idea of a virtual parent class. • If your parent is virtual there is one copy, and if not there is two. • Not a perfect solution, and makes the language complicated.
  • 17. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INNER CLASSES • The ability to next classes in C++ and Java provides a mechanism that is nearly equivalent to multiple inheritance, without the semantic problems. INNER CLASS class Child extends ParentOne { . . . class InnerChild extends ParentTwo { . . . / / can access both parents } }
  • 18. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References SUMMARY • In this chapter we have explored some of the problems that arise of the concept of multiple inheritance. • Name ambiguity. • Impact on substitution. • The Problem of Common Ancestors.
  • 19. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References REFERENCES • Images and content for developing these slides have been taken from the follwoing book with the permission of the author. • An Introduction to Object Oriented Programming, Timothy Budd. • This presentation is developed using Beamer: • Singapore, wolverine.