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()
  • 相关阅读:
    常用模块——time模块,datetime模块
    开发目录的规范

    模块
    day17作业
    面向过程编程
    函数递归
    谈谈作为一个菜B的培训感受
    絮叨机房精密空调的制冷剂
    接入机房产生冷凝水
  • 原文地址:https://www.cnblogs.com/BKY88888888/p/11278706.html
Copyright © 2011-2022 走看看