2 ms·
A singleton guarantees that one-and-only-one instance of that type/thing is instantiated. One can create as many global variables of that type/thing as one wan
by LgWoodenBadger 8y ago
A singleton guarantees that one-and-only-one instance of that type/thing is instantiated.
One can create as many global variables of that type/thing as one wants. Whether one refers to the same, singular instance everywhere is not something a global variable guarantees.
One may use a global variable to implement a singleton, but they aren't the same at all.