Professional Documents
Culture Documents
Lecture 05
Lecture 05
(OOP)
Lecture No. 5
Multiple Inheritance
Mermaid
Example – Multiple Inheritance
Woman Fish
Mermaid
Example – Multiple Inheritance
Amphibious Vehicle
Example – Multiple Inheritance
Vehicle
► Increased complexity
► Reduced understanding
► Duplicate features
Problem – Duplicate Features
Woman Fish
eat eat
… …
Mermaid
Woman Fish
eat eat
… …
Mermaid
Invoke eat
eat
operation of
… desired class
Problem – Duplicate Features
(Diamond Problem)
Vehicle
changeGear
► Object Association
Simple Association
Composition
Aggregation
Simple Association
lives-in
Ali House
1 1
drives
Ali Car
1 *
works-for
Employee Company
* 1
friend
Yasir Ali
1 1
works-for
Employee Company
* 1
drives
Ali Car
1 *
Student 1
Teacher
*
*
Course
Project * *
Language
1
Person
1
Body
Example – Composition of Chair
Back
1
Chair
2 1 4
Arm Seat Leg
Composition is Stronger
Bed
1
1
Cupboard
Example – Aggregation
Garden * Plant
Aggregation is Weaker
► Furniture
can be shifted to another room,
and so can exist independent of a particular
room
Example – Aggregation is Weaker