使类抽象的主要优点是什么 [英] What is the main advantage of making a class abstract

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

问题描述

为什么我们将一个类声明为抽象?我知道它无法实例化,但为什么要给它一个特殊的关键字。即使是正常类也可以正常工作,并且可以很容易地进行子类化。那么使一个类抽象的主要优点是什么?

Why do we declare a class as abstract? I know it cannot be instantiated, but why give a special keyword for it. Even a 'normal' class will work just as well and can be easily subclassed. so what is the main advantage of making a class abstract?

推荐答案

在抽象类中你可以实现一些方法并且可以做一些抽象您的所有客户也必须实施它。你可以提供一些常用的功能,你也可以在这里有一些继承的字段和一些骨架方法

In abstract class you can implement some method and can make some abstract all your client will have to implement it also. you can provide some common functionality , also you can have some inherited fields and some of the skeleton method here

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

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