The "is-a" Relationship
class NotificationSender:
def send(self, recipient: str, message: str):
raise NotImplementedError
class EmailSender(NotificationSender):
def send(self, recipient: str, message: str):
print(f"Connecting to SMTP server... Sending email to {recipient}")
Quick Summary
- Inheritance enables code reuse for true hierarchical relationships.
- Next, we explore Polymorphism — the real superpower of OOP.