There is base class A which has a method to load a data source.
Various classes are derived from A including derived class B.
Now I need to have a static member variable in class B e.g. mStaticOfB that is instantiated only once for ALL instances of class B to use.
The caveat here is that to instantiate the static mStaticOfB I need to use the data source inherited by base class A.But I need an instance of an object to get that and I don’t have it at that point.
How can I get arround this problem? Is there a good/standard way to handle this?The only idea that I came up (and trying not to use) is to make
class B a singleton.
What Nishant said, except threadsafe: