[Cs3] Singleton

Mikhail Nesterenko mikhail at cs.kent.edu
Wed Dec 13 20:42:56 EST 2017


> Just a quick question about Singleton pattern.
> 
> In the slides, Meyer's singleton uses a reference to a static local
> variable in order to prevent deallocation, yet the classic implementation
> returns a pointer to a dynamically allocated object.
> 
> My question is, could these be switched, or is the reference the reason
> that Meyer's singleton is the preferred implementation recently?
> 
> I guess I am just confused why classic doesn't use a reference, or why
> Meyer's doesn't use a pointer.

Both imlementations can be either reference or pointer-based. In the
examples, I have a pointer-based implementation of Meyer's singleton.

Thanks,
--
Mikhail


More information about the cs3 mailing list