Any class that declares an abstract method must itself be declared abstract.
声明抽象方法的任何类本身必须是声明为抽象的。
Offering both an interface and an abstract class is redundant, but I find it convenient: in most cases, I only need the abstract class, but the interface enables multiple inheritance.
同时提供接口和抽象类是多余的,但我发现这样很方便:在大多数情况下,我只需要抽象类,但接口支持多继承性。
It isn't always possible to define an interface in an abstract class, but in the light of evolution you should consider whether an abstract class is sufficient.
尽管并不是总能在抽象类中定义接口,但是在编程过程中总是免不了要考虑下一个抽象类够不够呢。
You can declare standard and abstract methods in an abstract class, as shown in Listing 5.
可以在抽象类中声明标准和抽象方法,如清单5所示。
Notice that an abstract class is denoted by italicized text, as are abstract methods.
注意,抽象类和抽象方法用斜体表示。
For those unfamiliar with themes, the abstract MetalTheme class offers a way to abstract away the colors and fonts used by the look and feel.
如果您不熟悉主题,那么抽象类MetalTheme提供了一个抽象外观使用的颜色和字体的方法。
Typically this is implemented by having an abstract class that has a static create method that returns a concrete object implementing the abstract class.
这种模式的典型实现方式是创建一个抽象类,其中具有静态方法create,这个方法返回的是实现了这个抽象类的一个具体对象。
abstract indicates to the compiler that, yes, this class is supposed to be abstract.
abstract为编译器指出,是的,这个类应该是抽象的。
This indicates that the BankAccount class is an abstract class and the withdrawal method is an abstract operation.
这表示,BankAccount类是一个抽象类,而withdrawal方法是抽象的操作。
A child class that extends an abstract class must implement all abstract methods in its parent or itself be declared abstract.
继承抽象类的子类必须实现在其父类或自身中声明为抽象的所有抽象方法。
Because having an abstract method makes it an abstract class. The reasoning is circular.
因为有一个抽象方法使得一个抽象类。推理是圆形的。
Each of these is an abstract class, complete with two non-abstract inner classes called Double and Float (which are subclasses of the abstract outer class).
其中每一个都是抽象类,他们都是两个名为Double和Float的非抽象内部类(它们是抽象外部类的子类)。
And, as you may have noticed, we could have achieved the same effect as the code in Listings 1-3 by using an abstract class (abstract classes are described in Chapter 6).
而且,正如你可能注意到的,我们可以通过使用抽象类获得与清单1 - 3代码同样的效果(抽象类是在第6章中描述的)。
That's is the reason abstract methods should be in abstract class (so that one cannot create the object for the abstract class) or interfaces only.
这是抽象的方法应该是抽象类的原因(使人不能创建抽象类的对象)或接口只。
What is the point of having non abstract methods in the abstract class if a new object of the abstract class can't be created?
具有非抽象方法的抽象类,如果一个新的抽象类的对象不能被创建的点是什么?
I understand that in abstract classes methods be both abstract, or not. But why can I not create an abstract method in a "normal", non-abstract class?
我的理解是,在抽象类中的方法都是抽象的,或不。但为什么我不能创建抽象方法在“正常”,非抽象类?
So, if you inherit the abstract class in multiple concrete classes, then the properties of the abstract class will be part of each table of the concrete class.
因此如果你在多个具体的类中,继承了抽象类的话,那么这个抽象类的属性将会是每一个具体的类(表)的属性的一部分。
However if you had an abstract method in a non-abstract class, you could instantiate the class and get an object, that would have an unimplemented method, which you would be unable to call.
但是如果你有一个摘要方法一非抽象班,你可以实例化类和对象,将未实现的方法,你将无法调用。
Linker error from not declaring abstract method in abstract base class?
链接错误不能声明抽象方法的抽象基类?
Because having an abstract method makes it an abstract class.
因为有一个抽象方法使得一个抽象类。
Derived classes of the abstract class must implement all abstract methods.
抽象类别的衍生类别必须实作所有抽象方法。
When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.
抽象类中可以有方法的实现,也可以指定方法的访问修饰符。
The abstract class contains abstract members.
抽象类包含抽象成员。
If the normal class contains abstract method, then one can creating the object for that class and may call the abstract method just like normal method.
如果正常类包含抽象方法,则可以创建该类的对象,可以调用抽象方法就像普通的方法。
An abstract class may contain abstract methods and accessors.
抽象类别可能会包含抽象方法和存取子。
Any class with an abstract method is automatically abstract itself, and must be declared as such. A class may be declared abstract even if it has no abstract methods.
任一类以一个抽象方法自动地是抽象的本身,且必须被声明,一个类可以被声明是抽象的既使它没有抽象方法。
An abstract class can have both abstract and non abstract methods.
抽象类可以有抽象和非抽象方法。
If you have an abstract class (any class with an abstract method becomes an abstract class), you can not create an object of that class.
如果你有一个抽象类(任何类的抽象方法成为一个抽象类),您不能创建该类的一个对象。
Q. are you still following the principle of Program to an interface if you are creating abstract methods in an abstract class that is not linked to an interface?
问:你还遵循面向接口编程的原则,如果你是一个抽象类,是不是与一个接口创建抽象方法?
An abstract class that implements an interface might map the interface methods onto abstract methods.
实作介面的抽象类别可能将介面方法对应到抽象方法。
应用推荐