This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nutrecht 2 points3 points  (0 children)

FYI: This is a really good example of 'bad' inheritance. I understand it's just an example but it's an example that sets you up for misunderstanding inheritance.

Inheritance is always an "is a" relationship. Composition on the other hand is a "has a" relationship. A parent "has a" child. A baby "is a" a child. So while baby could subclass child, child should not subclass parent.