Singleton Inheritance

后端 未结 4 1951
再見小時候
再見小時候 2021-02-20 00:28

How do I inherit from a singleton class into other classes that need the same functionality? Would something like this make any sense?

4条回答
  •  攒了一身酷
    2021-02-20 01:15

    You can inherit from singleton and for "reuse" or some fine tuning using templates (C++) or generics (C#.NET).

    I've posted in my blog (www.devartplus.com) a serie of posts in this subject:

    1) Basic singleton inheritance in C#.NET

    2) Thread-safe singleton inheritance in C#.NET

    3) Several singleton implementations in C++

    You are invited to visit those links, and share with all your opinion. Good luck.

提交回复
热议问题