   Problem with singleton!
  Alright, here's the problem.I made a CLogger class to log information throughout my game.  Logs are made by calling a Log member function within the class.I recently transformed this class into a singleton.  It is created with a static create function that returns a pointer to the new instance of the Logger.I have a global pointer that I set equal to this create function.My problem is that other, non dynamically allocated, classes try to use the Logger in their destructors.  Becuase I have to destroy the logger myself now (last thing I do in the program with a call to Logger::Destroy(), the logger disapears before my non dynamic global classes call their destructors.  Thus I get errors when I try to quit my game.  Anyone have any ideas on how to handle this?   
  Use one of Loki's SingletonHolder classes - they provide longevity management policies.   ;  This will delay the problem, but not actually solve it. The only way to handle it is to ensure that your classes are destroyed before the logger - for example by not havign any globals, and having all classes in main() or a class or fnction called from there. Anyway, just dosomething like this:class CLogger{   CLogger();public:   ~CLogger();   // Stuff   static CLogger& Get()   { static CLogger theLogger; return theLogger;   }};That way you don't need to free the logger, but it will be freed when the app exits (since its a global). Of course as I said, this won't work if you have other global classes since theres no way to specify the construction / destruction order.   ;  Well this sounds like a classic order of destruction scenario. Some options off of the top of my head:* You could go with a prepackaged solution like  Loki's SingletonWithLongevity template policy.* You might have some luck playing with atexit() manually, but this can also be sensitive to order of initialization problem.* Alternately, you can use a static counter initializer. That is, create a static/anonymous-namespaced object in every translation unit and have it access a global counter. The constructor for the class should increment the counter, and the destructor should decrement the counter. Only if the counter gets to zero should the object be destroyed.   ;  Or simply don't make the CLogger class a singleton.   ;  Just don't use singletons or globals, simple as that.   