>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:


[snip ... ]

very cute :-)

this works in the case of demoting a static constructor - which is handy to
know and exactly the situation here with Rohit's self-destructing
constructor.

but (as you pointed out) in general if the constructor is virtual you can't
demote from public to private

and ...

if it's some other function (not a constructor) you want to demote then
this trick won't work either because TObject.Create is always available
via a typecast:

               TObject(myGadget).ForbiddenProc;

Casting isn't a problem in the case of a static constructor because

               TObject(myGadget).Create;

is pretty silly  -  a derived class that does this deserves what it gets.

-ns




---------------------------------------------------------------------------
    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