Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #6
- #This program demonstrates the idea of inheritance
- class Store():
- """This is a superclass"""
- def __init__(self):
- self.owner="Boris"
- def exclaim(self):
- return "I'm defined in the superclass!"
- #This HardwareStore class will inherits the instance methods from a Store superclass
- class HardwareStore(Store):
- """This is a subclass"""
- pass
- #This is class object created from HardwareStore subclass
- home_depot=HardwareStore()
- print(home_depot.owner)
- print("\n")
- print(home_depot.exclaim())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement