问题描述
我已经对这个答案进行了大量的搜索,我得出了下面提到的结论。
我想知道它是否足够选择其中一个的理由是什么?
我尝试过:
当我们有一些默认的功能或方法时,使用抽象类,其定义对于所有子类来说都是相同的。因此,通过使用抽象类,我们不必一次又一次地编写相同的代码,即使将来如果我们需要更改我们只需要在一个地方进行更改所需的功能。
I have done lots of search regarding this answer and I've come up with conclusion mentioned below.
I want to know whether it is a fairly enough and a justified reason for choosing one over the other?
What I have tried:
Use abstract class when we have some default functionality or methods whose definition will remain same for all
the sub-classes. So by using abstract class, we do not have to write same code again and again, even in future if
we need to change the functionality we just need to make changes at a single place.
推荐答案
这篇关于我什么时候应该在界面上选择一个抽象类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!