"""
基于弱数据类型语言的特性,多态不是太明显
定义的时候不确定调用哪个类里面的方法,而是执行的时候才确定
"""
class Animal:
def introduce(self):
# 方法用于自我介绍
print("我是一只神奇的动物,感谢各位的关照!")
class Dog(Animal):
def introduce(self):
# 方法用于自我介绍
print("飞天旺财在此,感谢各位的关照!")
class Cat(Animal):
def introduce(self):
# 方法用于自我介绍
print("波斯猫垫着她的脚尖!")
def introduce(tmep):
# 方法用于
tmep.introduce()
a = Animal()
b = Dog()
c = Cat()
introduce(a)
introduce(b)
introduce(c)