[fpc-pascal] Implementing a true Singleton - Can we decrease the visibility of a method?
Graeme Geldenhuys
graemeg.lists at gmail.com
Fri Dec 8 10:27:19 CET 2006
On 12/8/06, Vincent Snijders <vsnijders at quicknet.nl> wrote:
> Maybe I am analyzing your output wrong, but to me it seems as if the contructor of
> TObject is called in the third case. printdata seems to print an empty text.
>
> So the protected contructor is unreachable, but the public constructor in TObject
> remains public.
That's correct, which is even worse. It gives us a half-baked object.
fData is never initialized. Putting a writeln() statement inside
TSingleton.Create shows that on the 3rd instance it is never executed.
[graemeg-linux] singleton > ./singtest
>> Tsingleton.Create
>> PrintData
hello world
---------
>> Tsingleton.Create
>> PrintData
hello world
hello world 2
---------
>> PrintData
--
Graeme Geldenhuys
There's no place like S34° 03.168' E018° 49.342'
More information about the fpc-pascal
mailing list