python是支持多重继承的
https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014318680104044a55f4a9dbf8452caf71e8dc68b75a18000
优先级 https://www.zhihu.com/question/54855335
从左到右,深度遍历。
这个例子可能更好些 https://blog.csdn.net/caiknife/article/details/8579851
class A(object):
def __init__(self):
super(A, self).__init__()
print("A!")
class B(object):
def __init__(self):
super(B, self).__init__()
print("B!")
class AB(A, B):
def __init__(self):
super(AB, self).__init__()
print("AB!")
class C(object):
def __init__(self):
super(C, self).__init__()
print("C!" )
class D(object):
def __init__(self):
super(D, self).__init__()
print("D!")
class CD(C, D):
def __init__(self):
super(CD, self).__init__()
print("CD!")
class ABCD(AB, CD):
def __init__(self):
super(ABCD, self).__init__()
print( "ABCD!" )
ABCD()
php虽然不支持多重继承,但是有新加的trait
定义上跟class完全一样,用的时候在子类内use就可以,并且func优先于父类的func
http://php.net/manual/zh/language.oop5.traits.php
sayHello();
?>