Setting a global variable
Hi gurus,
To express it simply, my problem is to access, from different classes, an instance of the object QThing.
It is possible to declare the object as a member variable in one class, and then exchange pointers *pCurrentThing with other classes. However, each time the active instance of the object changes, all the pointers in the other classes need to be updated.
Is there a way to declare a global pointer *g_pCurrentThing, for instance at "main" level, which could be seen by all the classes ? I've been unsuccessful so far.
Hope this is understandable :confused:
Thanks
andre
Re: Setting a global variable
Sounds to me that you are searching for a singleton pattern: See the our wiki article.
Re: Setting a global variable
Re: Setting a global variable
If you need just one object exactly then you can declare one static with global visibility.