class Man:
def eat(self):
print("饿了,吃饭!")
class Chinese(Man):
def eat(self):
print('用筷子吃饭')
class English(Man):
def eat(self):
print('用刀叉吃饭')
class Indian(Man):
def eat(self):
print('用右手吃饭')
def man_eat(m):
if isinstance(m,Man):
m.eat()
else:print('不吃饭')
p = Chinese()
man_eat(p)
多态实例
最新推荐文章于 2024-03-18 21:39:26 发布