具有所有具体方法的抽象类 [英] Abstract class with all concrete methods

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

问题描述

当类中的所有方法都是具体的时,是否有一些实际的编程情况让某人声明一个抽象类?

Are there some practical programming situations for someone to declare a class abstract when all the methods in it are concrete?

推荐答案

好吧,您可以使用模板方法模式,其中有多个覆盖点,它们都有默认实现,但组合的默认实现本身不合法 - 任何函数式实现必须子类化.

Well you could be using a template method pattern where there are multiple override points that all have default implementations but where the combined default implementations by themselves are not legal - any functional implementation must subclass.

(是的,我不喜欢模板方法模式;))

(And yes, I dislike the template method pattern ;))

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

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