Quantum wrote:
Hi,
What is the difference between a singleton class and a static class?
From what I can tell, they both offer the same functionality, i.e. only
one copy of a class.
Thanks,
Q
You can have many statics of the the same, but only one singleton:
class A {
//...
};
class B {
static A a1;
static A a2;
static A a3;
static B &singleton();
};
There isn't really any such thing as a static class, there are static
members - either attributes or methods.
Have a think about the static members of type A in B and then have a
think about the singleton B. You'll see that they don't offer the same
functionality in this example, although it is certainly possible to use
them in such a way that they can.
K