Board index » delphi » HIDE properties/procedures of an ancestor?

HIDE properties/procedures of an ancestor?

Hi,

If I do the following:

type
TFirstClass = class
private
  FProp1: integer;
public
  property Prop1: integer read FProp1 write FProp1;
end;

TSecondClass = class(TFirstClass)
private
public
end;

I think I can do now

var Second: TSecondClass;

Second := TSecondClass.Create;
Second.Prop1 := 10;

The problem is that I want to hide/kill that property... TSecondClass
has to be the same like TFirstClass, but the only difference is that
TSecondClass doesn't have a property TFirstClass has...

Is this possible?

 

Re:HIDE properties/procedures of an ancestor?


Quote
Alexander Lucke <ps...@anubis.psychologie.hu-berlin.de> wrote:

[snipped]

: The problem is that I want to hide/kill that property... TSecondClass
: has to be the same like TFirstClass, but the only difference is that
: TSecondClass doesn't have a property TFirstClass has...

: Is this possible?

Alexander,

  As far as I am aware, there is no way to reduce the visibility of an
inherited property, only to make it more visible. You could probably
create a dummy property with the same name which does nothing, but that is
not a particularly elegant solution.

  If anyone does have an answer, I would be quite interested to hear it as
well. Cc: to my e-mail would be greatly appreciated.

Jim.

--
------------------------------------------------------------------------------
Jim Kirk                   These opinions do not necessarily represent those
                           of my employer. If you agree with them, they are
jk...@primenet.com         mine. If you disagree, they are someone else's.
------------------------------------------------------------------------------

Re:HIDE properties/procedures of an ancestor?


Quote
Jim Kirk wrote:

> Alexander Lucke <ps...@anubis.psychologie.hu-berlin.de> wrote:

> [snipped]

> : The problem is that I want to hide/kill that property... TSecondClass
> : has to be the same like TFirstClass, but the only difference is that
> : TSecondClass doesn't have a property TFirstClass has...

> : Is this possible?

> Alexander,

>   As far as I am aware, there is no way to reduce the visibility of an
> inherited property, only to make it more visible. You could probably
> create a dummy property with the same name which does nothing, but that is
> not a particularly elegant solution.

        You certainly cannot reduce the visibility of an inherited
property in a descendant. The idea is that someone using a descendant
should be able to do anything that he could do with the base class, at
least formally - this wouldn't work if you could reduce visibility.

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Re:HIDE properties/procedures of an ancestor?


Somewhere in the Delphi docs, it explicitly says that you can't
"reduce" visibility on derived classes so, the compiler will enforce
this, so it's really the compiler which doesn't want you to do it.

bly

Quote
Jim Kirk <jk...@primenet.com> wrote:
>Alexander Lucke <ps...@anubis.psychologie.hu-berlin.de> wrote:
>[snipped]
>: The problem is that I want to hide/kill that property... TSecondClass
>: has to be the same like TFirstClass, but the only difference is that
>: TSecondClass doesn't have a property TFirstClass has...
>: Is this possible?
>Alexander,
>  As far as I am aware, there is no way to reduce the visibility of an
>inherited property, only to make it more visible. You could probably
>create a dummy property with the same name which does nothing, but that is
>not a particularly elegant solution.
>  If anyone does have an answer, I would be quite interested to hear it as
>well. Cc: to my e-mail would be greatly appreciated.
>Jim.
>--
>------------------------------------------------------------------------------
>Jim Kirk                   These opinions do not necessarily represent those
>                           of my employer. If you agree with them, they are
>jk...@primenet.com         mine. If you disagree, they are someone else's.
>------------------------------------------------------------------------------

Re:HIDE properties/procedures of an ancestor?


Quote
On Mon, 03 Feb 1997 04:18:50 GMT, b...@castle.net wrote:

Try overriding it in the private section, dont know if this works for
sure...

Other Threads