The function of static objects, such as global objects, will be guaranteed to be destroyed (provided that they are created).
The order of destruction is the reverse of yours.
Thus, if an object depends on another object during destruction, you must guarantee its availability. This is relatively simple, as you can force the order of destruction by making sure that the order of creation is done correctly.
The following link is about solid colors, but describes a similar situation and its solution:
Search for static C ++ initialization tasks
By extrapolating to the general case of lazy initialized globals, as described in the FAQ lite, we can solve the problem as follows:
namespace B { class B { ... }; B& getInstance_Bglob; { static B instance_Bglob; return instance_Bglob;; } B::~B() { A::getInstance_abc().doSomthing();
source share