我们是继承还是实现抽象类?

时间:2022-09-23 17:35:26

I have noticed that MSDN is very careful about the terms "inherit" and "implement".

我注意到MSDN对术语“继承”和“实现”非常谨慎。

We implement interfaces, but inherit non-abstract classes. 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).
  • 当抽象类由完整和抽象方法组成时,我们应该使用什么术语?抽象类一方面没有实例(这是接口的特征),另一方面它可能包含完整的方法(这是类的特征)。

1 个解决方案

#1


4  

I suppose that full methods of abstract class are inherited, but abstract methods are implemented.

我想抽象类的完整方法是继承的,但是实现了抽象方法。

NO. Abstract methods(defintion) are overridden by base class' overriding methods.

没有。抽象方法(定义)被基类的重写方法覆盖。

An abstract method declaration introduces a new virtual method but does not provide an implementation of that method. Instead, non-abstract derived classes are required to provide their own implementation by overriding that method.

抽象方法声明引入了新的虚方法,但未提供该方法的实现。相反,非抽象派生类需要通过覆盖该方法来提供自己的实现。

What term should we use when an abstract class consists of both full and abstract methods?

当抽象类由完整和抽象方法组成时,我们应该使用什么术语?

The definition of abstract class itself states that it could contain methods defintions as well, but it should have at least one abstract method.

抽象类本身的定义表明它也可以包含方法定义,但它应该至少有一个抽象方法。

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).

抽象类一方面没有实例(这是接口的特征),另一方面它可能包含完整的方法(这是类的特征)。

Abstract class is obviously a category of a class.

抽象类显然是一个类的类。

#1


4  

I suppose that full methods of abstract class are inherited, but abstract methods are implemented.

我想抽象类的完整方法是继承的,但是实现了抽象方法。

NO. Abstract methods(defintion) are overridden by base class' overriding methods.

没有。抽象方法(定义)被基类的重写方法覆盖。

An abstract method declaration introduces a new virtual method but does not provide an implementation of that method. Instead, non-abstract derived classes are required to provide their own implementation by overriding that method.

抽象方法声明引入了新的虚方法,但未提供该方法的实现。相反,非抽象派生类需要通过覆盖该方法来提供自己的实现。

What term should we use when an abstract class consists of both full and abstract methods?

当抽象类由完整和抽象方法组成时,我们应该使用什么术语?

The definition of abstract class itself states that it could contain methods defintions as well, but it should have at least one abstract method.

抽象类本身的定义表明它也可以包含方法定义,但它应该至少有一个抽象方法。

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).

抽象类一方面没有实例(这是接口的特征),另一方面它可能包含完整的方法(这是类的特征)。

Abstract class is obviously a category of a class.

抽象类显然是一个类的类。