As of late, I've chanced upon an acknowledgement/execution of the Singleton configuration design for C++. It has resembled this (I have embraced it from the genuine model):
// a lot of methods are omitted here
class Singleton
{
public:
static Singleton getInstance( );
~Singleton( );
private:
Singleton( );
static Singleton instance;
};
From this declaration, I can deduce that the instance field is initiated on the heap. That means there is a memory allocation. What is completely unclear for me is when exactly the memory is going to be deallocated? Or is there a bug and memory leak? It seems like there is a problem with the implementation.
My fundamental inquiry is, how would I carry out it in the correct manner?