Please see my other Web Development articles.
Modeling Real-World Objects through Relationship
These mechanisms work by relationships which may exist between classes.
Is-A Relationship (Inheritance)
Inheritance demonstrates the first type of relationship – is-a, where one class (Supervisor) “is-a” type of another class (Employee), and therefore inherits from that class.
Composition demonstrates another type of inheritance with a different type of relationship.
For example, each employee has a family.
Since the relationship between family and employee does not constitute an “is-a” type of relationship – a family is not a type of an employee, but an employee “has-a” family (optionally), the Employee class “has-a” Family class.