I have a singleton class defined in file x.h
class x
{
 public:
     static x* x_instance;
     static x* create_x_instance
     {
        if(!x_instance)
            x_instance = new x;
        return x_instance;
     }
     void someMemberFunction()
  private:
  x() { //some code}
};
extern x *x_interface;     
In x.cpp I have the following:
x *x::x_instance = 0;
x *x_interface = x::create_x_instance();   
In y.cpp, in the constructor of a another singleton class, I have
x_interface->someMemberFunction();    
I get a seg fault because y gets initialized before x. What is the correct way to solve this? I have read many articles on this, but I am still confused.
 
     
     
    