说明抽象方法只可以定义在抽象类中。如果不是这样的话,就会收到编译错误。
Note abstract methods can only be defined in abstract classes. If you attempt to do otherwise, you will be issued a compiler error.
如果这种方法从不叫,你不会得到错误,这意味着它是不是真的“乐于助人”的宣言,以同样的方式,将一个抽象的。
And if that method is never called, you won't get the error, which to means it's not really "obliging" the declaration in the same way an abstract def would.
链接错误不能声明抽象方法的抽象基类?
Linker error from not declaring abstract method in abstract base class?
不同的是,如果你可以使用抽象方法在这种情况下,你会看到一个“类必须实现的方法”的错误时,你试图运行你的代码(任何代码),以及你的IDE会突出显示错误。
The difference is that if you could use abstract methods in this case you'd see a "Class must implement method" error when you try to run your code (any code), and your IDE would highlight the error.
不同的是,如果你可以使用抽象方法在这种情况下,你会看到一个“类必须实现的方法”的错误时,你试图运行你的代码(任何代码),以及你的IDE会突出显示错误。
The difference is that if you could use abstract methods in this case you'd see a "Class must implement method" error when you try to run your code (any code), and your IDE would highlight the error.
应用推荐