> ... and I probably should have mentioned, the implementation of Tx.Create
> should be
> 
> constructor Tx.Create;
> begin
>     inherited Create;
> end;

[Tested in D4]
Whilst this may stop the code reaching the constructor the compiler will
still compile a line in a different unit
   x := TDescendant.Create;
even if the descendant does not declare a constructor... The program will
run using the code of the constructor one further step up the class-tree
producing unpredictable results. Hence you're back to a run-time ident
problem with unpredictable results... Better to make the public constructor
produce an exception and have a private constructor perform valid construction
from the class method that validates the construction process.

TSpam = class
private
    constructor _PrivateCreate;
public
    constructor Create;
end;

constructor TSpam._PrivateCreate;
begin
    inherited Create;
    // actual constructor code...
end;

constructor TSpam.Create;
begin
    inherited Create;
    // raise an exception with predictable results...
    raise Exception.Create("You cannot instantiate an instance of '+ClassName);
end;

--
Aaron Scott-Boddendijk
INTAZ Limited
+64 7 838 3371 Voice
+64 7 838 3372 Fax


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to