Chapter: 09          Inheritance                Lecture: 33              Date: 10.10.2012
Class Hierarchies
Public and Private Inheritanceclass employee         //base class{          };class teacher : public employee       //publ...
Public and Private Inheritance
Levels of Inheritance   Classes can be derived from classes that are themselves    derived.
Levels of Hierarchies
Multiple Inheritance   A class can be derived from more than one base class
Multiple Inheritance
Aggregation: Classes Within Classes   Both inheritance and aggregation are class    relationships.   Inheritance is “kin...
Aggregation: Classes Within Classes   Both inheritance and aggregation are class    relationships.   Inheritance is “kin...
Aggregation: Classes Within ClassesAggregation may occur when one object is an attribute of another.In other words, one cl...
Aggregation: Classes Within Classes
Aggregation: Classes Within Classes
Composition: A Stronger Aggregation   Composition is a stronger form of aggregation, having    all its plus two more    ...
Composition: A Stronger Aggregation   Composition is a stronger form of aggregation, having    all its plus two more    ...
Upcoming SlideShare
Loading in …5
×

Lec 33 - inheritance

202 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
202
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Student Book
  • Student Book
  • Student Book
  • Student Book
  • Student Book
  • Student Book
  • Student Book
  • Student Book
  • Lec 33 - inheritance

    1. 1. Chapter: 09 Inheritance Lecture: 33 Date: 10.10.2012
    2. 2. Class Hierarchies
    3. 3. Public and Private Inheritanceclass employee //base class{ };class teacher : public employee //publicly-derived{ };class teacher : private employee //privately-derived{ };
    4. 4. Public and Private Inheritance
    5. 5. Levels of Inheritance Classes can be derived from classes that are themselves derived.
    6. 6. Levels of Hierarchies
    7. 7. Multiple Inheritance A class can be derived from more than one base class
    8. 8. Multiple Inheritance
    9. 9. Aggregation: Classes Within Classes Both inheritance and aggregation are class relationships. Inheritance is “kind of” relationship - association. Aggregation is “has a” relationship - association Def. Aggregation - Several things grouped together or considered as a whole.
    10. 10. Aggregation: Classes Within Classes Both inheritance and aggregation are class relationships. Inheritance is “kind of” relationship - association. Aggregation is “has a” relationship - association Def. Aggregation - Several things grouped together or considered as a whole.
    11. 11. Aggregation: Classes Within ClassesAggregation may occur when one object is an attribute of another.In other words, one class contains objects of another class.Example:class A { };class B { A objA; //object of class A is an attribute of class B };
    12. 12. Aggregation: Classes Within Classes
    13. 13. Aggregation: Classes Within Classes
    14. 14. Composition: A Stronger Aggregation Composition is a stronger form of aggregation, having all its plus two more  The part may belong to only one whole  The lifetime of the part is the same as the lifetime of the whole While aggregation is a “has a” relationship, composition is a “consists of” relationship.
    15. 15. Composition: A Stronger Aggregation Composition is a stronger form of aggregation, having all its plus two more  The part may belong to only one whole  The lifetime of the part is the same as the lifetime of the whole While aggregation is a “has a” relationship, composition is a “consists of” relationship.

    ×