RAD Studio (Common)
ContentsIndex
PreviousUpNext
W1009: Redeclaration of '%s' hides a member in the base class (Delphi)

A property has been created in a class with the same name of a variable contained in one of the base classes. One possible, and not altogether apparent, reason for getting this error is that a new version of the base class hierarchy has been installed and it contains new member variables which have names identical to your properties' names. -W

(*$WARNINGS ON*)
program Produce;

  type
    Base = class
      v : integer;
    end;

    Derived = class (Base)
      ch : char;
      property v : char read ch write ch;
    end;

begin
end.

Derived.v overrides, and thus hides, Base.v; it will not be possible to access Base.v in any variable of type Derived without a typecast.

(*$WARNINGS ON*)
program Solve;
  type
    Base = class
      v : integer;
    end;

    Derived = class (Base)
      ch : char;
      property chV : char read ch write ch;
    end;

begin
end.

By changing the name of the property in the derived class, the error is alleviated.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!