Source: 📖 Problem Solving with Algorithms and Data Structures using Python 1.13.2
Date: 2021-10-27
An IS-A relationship is when classes follow a hereditary structure. For example, if class A
is subclassed by class AChild
, then we can say that class AChild
IS-A subclass of class A
.
A HAS-A relationship is when a class uses another class, but it does not reside within that class' hierarchy. Suppose that class B
'holds' an instance of class A
as a property value, then we would say that class B
HAS-A class A
instance.