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

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

问题描述

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

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天全站免登陆