In C ++, declaring a global instance of a class is no-no.
Instead, you should use the singleton template, which gives you one instance of your object, accessible from the entire application.
You can find a lot of literature on implementing a singleton C ++, but wikipedia is a good place to start.
The implementation of a singleton streaming template has already been discussed in stackoverflow.
Daniele milan
source share