Singleton Classes and Self-Instantiating Classes
Assume you want to design a class to facilitate output to the screen or printer. What’s special in this case is that you must have control over the instantiation of this class. It’s not enough to leave the number of instantiations to the class itself. After all, a certain printer exists only once, and can’t have multiple instances of the same class in memory.
An abstract class with static procedures (or a module) could possibly be an alternative, but the problem is that neither the functions of a module nor the static function of an abstract class can be overridden in other classes.
The solution is Singleton classes. Unlike the different variants of classes to which you have been introduced so far, ...