Singleton delete instance
In a simple Singleton pattern written in C++ how is it possible to delete the instance? (Apparently this pattern is very simple but I have realized that, in a lot of implementations, the instance was not really deleted). As the user member "dmail" commented, he uses a "getinstance" function to get a reference (a pointer is also possible) to the instance created, then he also registers an "atexit" function to delete the instance.
But, does not exist another solution without registering an atexit function in order to delete the instance?
Thanks.
|