Chapter 5 Flashcards
What is multiple inheritance
A class inherited by more than one class
What is diamond problem
In multiple inheritance, if intermediate classes inheriting from same base class then the 3rd level of child class will have same behavior from two classes. It is called diamond problem.C++ gives solution to it that inheritance should be from only any one root.
What is association in OO
object interaction with each other is called association
What are 2 main types of associations
- Class association (inheritance)
- Object association (simple association, composition, aggregation)
Note: object must have reference of one another.
What is simple association
It is the weakest link between objects. It is the reference by which one object can interact with some other object.
What are sub types of simple association
w. r.t. navigation
- One-way association (single direction)
- Two-way association (both direction)
w. r.t. number of objects
- Binary association (2 objects interact)
- Ternary association (3 objects interact)
- N-ary association (more than 3 objects interact)
What is composition
An object may be composed of other smaller objects. It is called composition. Smaller objects are part of main object and it is strong relationship. A smaller object can not sustain independently. The relationship between objects is whole-part.
What is aggregation
An object may contain a collection of other objects. The relationship between the contained objects and container object is called aggregation. It is a weak relationship because aggregate object is not part of container and it can exist independently.