Inheritance defined |
When we inherit a class, our new object or class (the subobject or subclass) "inherits" everything that is defined in the first class. We can use the things that we have inherited as if we had defined them in the subclass.
So when we declare that an object inherits graphicApplication, we can use the canvas instance variable defined in graphicApplication, we can call methods like append and prepend defined in graphicApplication, and get or set the windowTitle application (which graphicApplication inherits from. When we used these methods, we called them as if they were locally defined, usually just with the method name, though we could have specified the optional self. prefix to clarify that the method is part of this class, or as we have now seen, part of a class we extended. Our class that inherits graphicApplication need only define that which is different - the exact components on the display and how they react to input.
Inheritance defined |