zoukankan      html  css  js  c++  java
  • 多重继承

     1 #  太爷爷 -> 爷爷 -> 爸爸 -> 儿子
     2 # 单继承 : 一个父类对应一个子类
     3 # 多重继承 : 子类有父类,父类有父类 。。。。
     4 class YeYe():
     5     def __init__(self, house):
     6         self.house = house
     7         self.__wan = "古董"
     8     def merry(self):
     9         print("爷爷和奶奶结婚了")
    10 class Father(YeYe):
    11     def __init__(self, house, car):
    12         YeYe.__init__(self, house)
    13         self.car = car
    14     def merry(self):
    15         # YeYe.merry(self)
    16         print("爸爸和妈妈结婚了")
    17     def work(self):
    18         print("爸爸上班")
    19 class Son(Father):
    20     def __init__(self, house, car, computer):
    21         Father.__init__(self, house, car)
    22         self.computer = computer
    23     def merry(self):
    24         Father.merry(self)
    25         print("就找女朋友,不结婚")
    26 
    27 son1 = Son("大房子", "二手奥拓", "dell")
    28 print(son1.house, son1.car, son1.computer)
    29 son1.merry()
  • 相关阅读:
    java中的lamda表达式
    Arrays.sort()中Lambda表达式
    检索中的函数及不同范围的处理
    2014.6.24
    2014.6.23
    第六天培训
    第五天培训
    第四天培训
    第三天培训!
    第二天培训
  • 原文地址:https://www.cnblogs.com/BKY88888888/p/11278706.html
Copyright © 2011-2022 走看看