我注意到 MSDN 对“继承”和“实现”这两个术语非常谨慎。
我们实现接口(interface),但继承非抽象类。 我认为抽象类的完整方法是继承的,但是 实现了抽象方法。
- 当抽象类同时包含完整方法和抽象方法时,我们应该使用什么术语?抽象类一方面没有实例(这是接口(interface)的特征),另一方面它可能包含完整的方法(这是类的特征)。
最佳答案
I suppose that full methods of abstract class are inherited, but abstract methods are implemented.
不。抽象方法(定义)被基类的重写方法重写。
抽象方法声明引入了新的虚拟方法,但不提供该方法的实现。相反,非抽象派生类需要通过重写该方法来提供自己的实现。
What term should we use when an abstract class consists of both full and abstract methods?
抽象类本身的定义表明它也可以包含方法定义,但它应该至少有一个抽象方法。
Abstract class has no instances on one hand (this is a characteristic of an interface), on other hand it may contain full methods (this is a characteristic of a class).
抽象类显然是类的一个类别。
关于.net - 我们继承还是实现抽象类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35610682/