#继承
#object base class, which is the parent class for all classes defined by Python
#经典类: Classes that do not inherit object are called Classic classes
#新式类: Classes that inherit object are called modern classes
#python 3.x unified for new class
#经典类是类对象, a new class is a type Object
#经典类的继承是按照继承的顺序进行继承的
#新式类是按照修改的优先级来继承, the higher the change priority is.
Class Parent: #定义一个父类
def __init__ (self):
Self.age = 0
def sing (self):
Print ("Sing a Song 2")
Class Child (Parent): #定义一个子类
def sleep (self):
Print ("Zzzzzzz ....")
def sing (self): #重写, retains the parent property while having its own property
Parent.sing (self)
Print (self)
Print ("Sing a Song 1")
Father = Parent ()
son = Child ()
Print (Son.age)
Son.sing () #---> child.sing (son)
"""
0
Sing a Song 2
<__main__. Child object at 0x00000000007ecef0>
Sing a Song 1
"""
The inheritance of the three major features of Python object-oriented