什么是主要的diffrenace黑白接口和抽象类 [英] What is the major diffrenace b/w interface and abstract classs

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

问题描述

什么是主要的差异黑白接口和抽象类

解决方案

请参考下面的链接。它给你更好的想法



抽象类与接口 [ ^ ]


< blockquote>简单:一个抽象类可以包含代码,一个接口不能。



这意味着一个Abstract类可以包含使类工作的基本代码,以及派生类只需要实现特定于该类的额外代码。使用界面,所有派生类都必须提供所有代码。



此外,在大多数语言中,您只能从单个类派生:但您可以添加尽可能多的界面。您不能从两个抽象基类派生。


What is the major diffrence b/w interface and abstract classs

解决方案

Please refer below link.It gives you the better idea

Abstract Class versus Interface[^]


Simple: an Abstract class can contain code, an interface can't.

This means that an Abstract class can contain basic code for getting a class working, and the derived class only has to implement the extra code which is specific to that class. With an interface, all code must be provided in all derived classes.

In addition, in most languages, you and only derive from a single class: but you can add as many interface as you need. You cannot derive from two abstract base classes.


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

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