How to implement singleton without using static/global variable? Possible?

前端 未结 3 2018
半阙折子戏
半阙折子戏 2021-01-06 19:08

How to implement singleton without using static/global variable? Possible?

This is an interview question...

相关标签:
3条回答
  • 2021-01-06 19:23

    Dependency injection is one possibility. Since your question is not specific to any programming language, I am not posting framework specific syntax (such as Ninject)

    0 讨论(0)
  • 2021-01-06 19:24

    Store the singleton in a file.

    0 讨论(0)
  • 2021-01-06 19:38

    No. You need a place to store the singleton.

    0 讨论(0)
提交回复
热议问题