From: Nello Sestini [mailto:[EMAIL PROTECTED]]
> Even with that, it would be difficult to prevent a derived class from
> calling the wrong Create though since you can't "demote" a method from
> protected to private.
Well, actually, you can, using a trick. The trick is to know that (from the
help) "If you declare a method in a derived class with the same name as a
static method in the ancestor class, the new method simply replaces the
inherited one in the derived class." So the following would demote Create
to private:
unit Unit1;
interface
type
Tx = class(TObject)
private
{
Create a new constructor, Create. This supersedes and effectively hides
TObject.Create, which is not virtual.
}
constructor Create;
end;
{
Essential to have the descendant class in a different unit, as otherwise
TObject.Create is still accessible!!
}
unit Unit2;
interface
type
Ty = class(Tx)
{
Better add a new constructor now, because you can't call Ty.Create any
more...
}
end;
Cheers,
Carl
---------------------------------------------------------------------------
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"