What’s the point of inheritance in Python?

前端 未结 11 2107
一向
一向 2020-12-12 10:11

Suppose you have the following situation

#include 

class Animal {
public:
    virtual void speak() = 0;
};

class Dog : public Animal {
             


        
11条回答
  •  北海茫月
    2020-12-12 11:15

    Inheritance in Python is all about code reuse. Factorize common functionality into a base class, and implement different functionality in the derived classes.

提交回复
热议问题