为什么抽象方法只能在抽象类中声明? [英] Why can abstract methods only be declared in abstract classes?

查看:27
本文介绍了为什么抽象方法只能在抽象类中声明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在抽象类中,方法既是抽象的,也不是抽象的.但是为什么我不能在正常"的非抽象类中创建抽象方法?

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?

提前感谢您的解释!

推荐答案

Abstract 方法基本上是说,该方法没有实现,需要在子类中实现.但是,如果您在 非抽象 类中有一个 抽象 方法,则可以实例化该类并获取一个对象,该对象将有一个未实现的方法,您将无法实现打电话.

Abstract method basically says, that there is no implementation of the method and it needs to be implemented in a subclass. 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.

这篇关于为什么抽象方法只能在抽象类中声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆