[ fromfile: globals.xml id: globals ]
There are two reasons generally used to justify giving an object global scope.
It needs a lifetime that is the same as the application.
It needs to be accessible from several different places in the application.
In C++, you should avoid the use of global scope as much as possible and instead use other mechanisms. However, you can still use global scope identifiers for the following:
Class names
Namespace names
The global pointer qApp
, which points to the running QApplication object.
By turning a global object into a static class
member, or a namespace
member, you can avoid increasing the size of the global namespace while keeping
the object accessible to several source code modules.
[114] By "interesting" we mean any class with a destructor that has some important cleaning up to do.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |