We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7666a9a commit 445ba9dCopy full SHA for 445ba9d
test23.py
@@ -0,0 +1,40 @@
1
+#!/usr/bin/env python3
2
+# -*- coding: utf-8 -*-
3
+
4
+'练习面向对象高级特性的多继承'
5
6
+__author__ = 'sergiojune'
7
8
9
+class Animal(object):
10
+ pass
11
12
13
+class Bird(Animal):
14
15
16
17
+class Mammal(Animal):
18
19
20
21
+# 加个扩展功能
22
+class Flyable(object):
23
+ def fly(self):
24
+ print('fly------------')
25
26
27
+class Runnable(object):
28
+ def run(self):
29
+ print('run-----------')
30
31
32
+# 这样就是多继承,加了和功能
33
+class Dog(Mammal, Runnable):
34
35
36
37
+# 多继承从做往右继承,在父类中有相同的方法时就会先实现左边的方法,就近原则
38
+class Parrot(Bird, Flyable):
39
40
0 commit comments