I want to make a generic singleton class which I can create a is-a relationship with.
Looking around a bit I found something like this:
Code:
template <class T> Singleton{
protected:
Singleton();
~Singleton();
static T* m_pInstance;
....
public:
static T* getInstance(){....}
};
Would something like this work if I had two different classes say Foo and Bar which inherit from Singleton.
Singleton<Foo>::getInstance()->FooFunc();
Singleton<Bar>::getInstance()->BarFunc();
I think it should work since there would be two versions of m_pInstance... the one for class Foo and one for class Bar...