Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 370013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:58:37+00:00 2026-05-12T13:58:37+00:00

I have 3 interface classes IVideo , IAudio , IGPIO and three other classes

  • 0

I have 3 interface classes IVideo , IAudio , IGPIO and three other classes that will implement those interface: Video_impl , Audio_impl , GPIO_impl.

Things is simple so far.

But then ,I want all those object to be singleton. Here are the questions:

Is it a good idea to abstract an Interface ISingleton , so that Video_impl , Audio_impl , GPIO_impl (or IVideo , IAudio , IGPIO ?) can inherit from it?

I was thinking of implement it in following way. Is it recommended? I think there must be better ways.

//Isingleton.hpp
template <class T>
class ISingleton
{
public:
virtual T *getInstance() = 0;

};

class IGPIO
{
public:
virtual int SelectAudioInput() = 0;
};

class GPIO_impl : public IGPIO, public ISingleton<IGPIO>
{
public:
    IGPIO *getInstance();
    int SelectAudioInput() ;
private:
    IGPIO *instance;
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:58:37+00:00Added an answer on May 12, 2026 at 1:58 pm

    I would recommend reading Alexandrescu’s “Modern C++ Design”. In it, among many other things, he designs a fully-fledged singleton template and thinks through many of the issues, such as when it should be destroyed, whether it should resurrect after being destroyed because it is needed during the destruction of other singletons, and all that good stuff.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an interface which will be implemented by classes that take care of
I have an interface that I want to implement in separate classes after doing
If I have interface IFoo, and have several classes that implement it, what is
I have an interface, IFindable that is implemented by a few classes. One other
Let's say I have an interface IAutoTask and few other classes implementing that interface,
I have an interface and three classes which implements that interface and i should
I have an Interface called as IObSrc, I have few classes that implement this
If I have an interface and many classes that implement this interface, can I
I have an interface for a variety of classes, all of which should implement
I have an interface, and some classes that inherit from it. public interface IFoo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.