3. Public and Private Inheritance
class employee //base class
{ };
class teacher : public employee //publicly-derived
{ };
class teacher : private employee //privately-derived
{ };
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. 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. Aggregation: Classes Within Classes
Aggregation 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
};
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. 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.