More good stuff: a Singleton
Somehow there should be one and only one factory. If we allow two different factories to coexist, we are in trouble. We want to make it so that the first instance of a HistogramFactory object prevents all other instances from being created. This is called a Singleton.
Let’s look at a part of the RootHistogramFactory class declaration:
class RootHistogramFactory : public HistogramFactory {
static RootHistogramFactory *buildFactory();
static int deleteFactory();
RootHistogramFactory::RootHistogramFactory();
RootHistogramFactory::~RootHistogramFactory();
static RootHistogramFactory *single;
A protected constructor?!?