Welcome! and rules
Joel on Software
i have a class A and I have a singleton class B.
Not 100% sure I understand the question, but the (sole) instance of a singleton class B should be created in its GetInstance() method or equivalent, like this:
Here u have this method GetInstance in B. MY question is Should i call this .GetInstance from the constructor of A....??
It's up to you. Creating a new object has some overhead, so if you may not use it at some point (say it depends on something else), just wait to create it until you need it really. Then any subsequent time the overhead of constructing the object is gone.
I make all the methods and member data of B static, give B a static constructor, and therefore don't explicitly instantiate B from A: have a static B() ensures that B is constructed automatically when any of its static methods is invoked; note that I can't pass parameters to the static B constructor.
Fog Creek Home