纯抽象类和接口 [英] pure abstract class and interface

查看:105
本文介绍了纯抽象类和接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我完全抽象的类和接口之间究竟有什么区别吗?

Can anyone tell me what exactly the difference between an completely abstract class and an interface?

Abstract类也可以将其所有方法都抽象化。接口的所有方法都是抽象的。在这种情况下,两者之间的主要区别是什么?

An Abstract class can also have all its methods as abstract. An interface has all its methods as abstract. What is the main difference between the two in this scenario?

如果纯抽象类和接口之间存在差异?界面有什么用?在使用接口的地方,我们可以使用纯抽象类?

If there is difference between a pure abstract Class and interface? What is the use of interface? Where interface is being used we can make use of pure abstract class?

推荐答案

要完成以前的答案:

界面是一个合同。如果类实现了接口,则必须提出接口中列出的所有服务。

An interface is a "contract". If a class implements an interface it have to propose all the services listed in the interface.

抽象类是骨架。它定义了扩展类的某种方式,同时让它们有一些自由空间(抽象方法)是唯一的。

An abstract class is a skeleton. It defines a certain way its extended classes will work while letting them some free space (the abstract methods) to be unique.

一个纯粹的抽象类与接口做同样的事情但是有独特的扩展问题所以,对我来说,它没有兴趣

A pure abstract class doing the same thing as a interface but have the problem of unique extending so, for me, it have no interest

这篇关于纯抽象类和接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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