Singleton allows me to have a sort of global object with a class/method interface instead of a plain global variable. Also, Class::WeakSingleton allows me to have a singleton that can expire when no more references to the object remain. It just makes for a handy way to pass data around sometimes. I use it for a place to stash some data that is used in a database wrapper and then re-used later deep in the database hook methods. It would have been difficult to put the data into the database and awkward to just have a global - so a comprimise.
In reply to Re: Singleton vs Static
by diotalevi
in thread Singleton vs Static
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |