Hi, I was reading this book, and came across this code regarding the Singleton class, and extending this class:
As you can see, the uniqueInstance variable is present in both classes.
Obviously we need it in the superclass, but why is it present in the subclass?
I did a little
test, and it seems they are equal.
Is this just for clarity? What generally happens with variables of the same name in a superclass and subclass?
Thanks for any info.
I've just re-read the post, and noticed the uniqueInstance gets sets to the type of the superclass, so surely this won't work since we want a CoolerSingleton object stored there?
[ May 14, 2007: Message edited by: colin shuker ]