Hi Nello,
The key words in that statement are "in the derived class". Yes, SomeProc
will call TBase.DoSomething, not TDerived.DoSomething. That's static
methods for ya - no way to avoid it. :-)
Cheers,
Carl
-----Original Message-----
From: Nello Sestini [mailto:[EMAIL PROTECTED]]
Sent: Friday, 27 October 2000 12:35 PM
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Free inside Create
Earlier, Carl pointed out...
>... "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."
I've been thinking about this some more - this is very disturbing
behaviour.
Suppose i have
type
TBase = class(TObject);
Public
procedure DoSomething;
end;
TDerived = class(TBase);
private
procedure DoSomething;
end;
and elsewhere in some other unit I have some function
procedure TSomeUnit.SomeProc( aBase: TBase );
begin
aBase.DoSomething;
end;
and now in a 3rd unit I have
var aDerived:TDerived;
aDerived:=TDerived.Create;
SomeProc( aBase );
does this call the TBase.Dosomething - even though it's "replaced"
by the derived one?
or does this call the TDerived.DoSomething (since it "replaces" the
inherited version) - effectively circumventing the "Private"?
I haven't tried this yet - but regardless of which happens, isn't
this a bit bizarre? Am I missing something?
-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"
---------------------------------------------------------------------------
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"