How can a singleton class use an interface?

后端 未结 5 1888
盖世英雄少女心
盖世英雄少女心 2021-02-04 11:09

I read at many places that singletons can use interfaces. Some how I am unable to comprehend this.

5条回答
  •  说谎
    说谎 (楼主)
    2021-02-04 11:28

    A singleton has an instance - it just never has more than one instance. You probably use a couple of static members for reference-fetching and to ensure that it never gets multiple instances, but for the most part the class is the same as any other class.

提交回复
热议问题