December 2012
Intermediate to advanced
316 pages
6h 51m
English
A
singleton class is a class that can have only one instance at a time. Any attempt to create a second or more instances should not be allowed. This recipe shows how to create a class based on the singleton design.
We will use the same class created in the last recipe of factory method. We will make few changes to the class so that we can prevent the creation of multiple instances of the class. We will make a copy of the class (program) shown in the previous recipe and modify it. The name of the copy is singleton_class.
For creating a singleton class, follow these steps:
CREATE PRIVATE addition is included in the singleton class definition.Read now
Unlock full access