I think I know what you mean. This is accomplished by a pattern known as Singleton
. With a singleton class you get a class that exists in exactly one instance and every component of your program can access that same object. Is this what you need? Then look at this:
The class declaration (.hh-file):
// Singleton pattern
static MySingletonClass *Instance();
//Hide constructor and destructor from public
}; //class MySingletonClass
The class definition (.cc-file):
// Since the variable is static, this statement will only be
// executed once, the first time execution reaches this point
static MySingletonClass *sing = new MySingletonClass();
} //MySingletonClass *MySingletonClass::Instance()
Usage of the instance:
// The Instance() method is static and can be accessed anywhere
// without any object reference.
Good luck with your project!