Best way to elaborate on the question is to give an example of what I'm trying to do...
I define a "base class":
TMyBaseClass = class(TPersistent)
protected
procedure Foo(const AValue: String); virtual;
// more methods here (many more in fact)
end;
I now define a descendant class:
TMyDescendantClass = class(TMyBaseClass)
public
procedure Foo(const AValue: String); override;
// etc. for all desired methods I wish to elevate into Public
end;
The problem here is that I then have to redefine the method "Foo" for TMyDescendantClass to pass the call up the chain to TMyBaseClass:
procedure TMyDescendantClass.Foo(const AValue: String);
begin
inherited;
end;
This is a waste of space! I'm wondering if anyone knows of any way to negate the need to reimplement the method and acll "inherited".
An ideal solution would look something like:
TMyDescendantClass = class(TMyBaseClass)
public
procedure Foo(const AValue: String); elevated;
// etc. for all desired methods
end;
Obviously this is hypothetical, and I know the keyword "elevated" does not exist in the Delphi language. Is there a keyword with the same effect I just don't know about?
Thanks!
There is no such keyword. You can trivially change the visibility of a property by redeclaring it with a new visibility level. But there is nothing analogous for a method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With