Graeme Geldenhuys schreef:
On 12/8/06, Vincent Snijders <[EMAIL PROTECTED]> 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.
I think the solution is to create a public constructor which throws an
NotImplemented exception or something like that.
Then you create a protected (or private) constructor
constructor CreateSingletonInstance;
which is accessible only in that unit.
Note: instead of making function GetSingleton : TSingleton; a global function you
could make it class function GetInstance too.
Vincent
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal