Discuss / Python / 继承,多态

继承,多态

Topic source

Solo_Travel

#1 Created at ... [Delete] [Delete and Lock User]

class Animal(): def run(self): print("'Animal is running...'") class Dog(Animal): def run(self): print("('Dog is running...'") class Cat(Animal): def run(self): print("'Cat is running...'") animal=Animal() dog=Dog() cat=Cat()

def run_twice(animal): animal.run()


  • 1

Reply