abstract method use vs regular methods

前端 未结 6 1176
醉酒成梦
醉酒成梦 2021-01-13 06:45

I would like to know the difference between two conventions:

  1. Creating an abstract base class with an abstract method which will be implemented later on the der
6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-13 06:59

    In the case 1) you can access those methods from the abstract base type without knowing the exact type (abstract methods are virtual methods).

    The point of the abstract classes is usually to define some contract on the base class which is then implemented by the dervied classes (and in this context it is important to recognize that interfaces are sort of "pure abstract classes").

提交回复
热议问题