如何使其他类派生自单例类? [英] How do I make other classes derive from a singleton class?
问题描述
如果这是重复或过于简单,我很抱歉,但如何创建可以进行子类化的单例类?
I am sorry if this is a duplicate or too elementary, but how do I make a singleton class that can be subclassed?
推荐答案
Steve Yegge有一个有趣的文章关于单身人士提到在这个引用中的子类化:
Steve Yegge has an amusing article about singletons that mentions subclassing in this quote:
然后是子类化的东西。
几乎不可能将
Singleton子类化,如果你管理它,那么
你不应该首先使用
Singleton。你
不甚至想去那里。我花了b $ b走路,我不敢讲述。
只是假装你不能这样做,并且
你将为自己节省惊人的金额
的痛苦。
Then there's the subclassing thing. It's almost impossible to subclass a Singleton, and if you manage it, then you shouldn't have been using a Singleton in the first place. You don't even want to go there. I've walked roads that I dare not recount. Just pretend you can't do it, and you'll save yourself amazing amounts of pain.
这篇关于如何使其他类派生自单例类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!