+So what does inheritance do for us? Well, it allows us to create classes (called a derived, child, or subclass) using other classes (called a base, parent, or super class). This creates an **is-a** relationship - a derived class (`oHuman`, `oPet`, `oDog`, `oCat`) **is-a** base class (`oAnimal`). On the flip side, a `oHuman` **is not a** `oPet`. This makes it easier for us to reuse code (because good programmers are lazy) and create software that is flexible and easily maintainable. For example, take a gander to the image on the right. Imagine that we’re creating a game involving walking humans, dogs, and cats. We did our market research and found that walking animals aren’t what the hip, cool kids are looking for nowadays - they want [flying animals](http://i.ytimg.com/vi/QH2-TGUlwu4/hqdefault.jpg). Well, there’s two ways of doing this: 1) adding flight capability to each class (`oHuman`, `oDog`, and `oCat`), or 2) adding `flight = true` to our parent class (`oAnimal`), have the change trickle down to it’s child (and grandchildren) classes, and be on our merry way. What would you chose? 1 or 2?
0 commit comments