开发者

Redeclaration hides member in base class

开发者 https://www.devze.com 2023-01-25 21:05 出处:网络
I am trying to clean up compiler warnings in an application I inherited. One of our classes inherits from TControl. The warning I am getting is \"Redeclaration of Changed hides a member in the Base cl

I am trying to clean up compiler warnings in an application I inherited. One of our classes inherits from TControl. The warning I am getting is "Redeclaration of Changed hides a member in the Base class"

"Changed" is a protected procedure in TControl. The class I am looking at has overridden it with a boolea开发者_Python百科n property

property Changed : Boolean read FChanged write FChanged stored true;

There are a few options I have ruled out already:

  1. Rename from "Changed" to something else. This is not a practical option, as this property is used everywhere in the application.

  2. Hide the warning using compiler directives. I can do this but I would prefer to find out what the warning means and how to correct it.

So my question is:

1) Is this warning actually a problem? What are the implications of "hiding the base member"?

2) How can I remove the compiler warning without renaming the property or hiding the warning?

I am using Delphi 2010

[Edit: There have been a few suggesions of using the refactoring tool to rename the offending property. I have ruled this out as the refactoring tool doesn't work at all on this codebase]


If your own 'Changed' was a procedure as well, you could use the override directive to tell the compiler that you add functionality to the base Changed method in TControl. If your declaration differs or you want for some other reason to break the chain of inheritance, you could specify the reintroduce directive to tell the compiler that you conciously break the chain.

Unfortunately this is not possible with properties, so there is no real solution for your problem, other than

  1. Rename 'Changed' to something else
  2. Hide the warning using directives
  3. Don't inherit from TControl

I would opt for the first option. Since you are using Delphi 2010, you can use the Refactoring tools in Delphi to rename the property thoughout your application, although I would thoroughly check the modifications before making them final, because maybe they will affect the Changed method in the base class as well...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号