Python Middle-class member functions are the understanding of virtual functions

xiaoxiao2021-03-06  167

Python's membership function is virtual function, we can see its power by the following functions:

Class A:

Def foo (Self): Print 'a'

Class B (a):

Def foo (Self): Print 'b'

For x in [a (), b ()]:

x.foo ()

The result we will get is

a

B

转载请注明原文地址:https://www.9cbs.com/read-128162.html

New Post(0)