[fpc-pascal] warning about hiding method in ancestor class

Xiangrong Fang xrfang at gmail.com
Sun May 4 16:46:55 CEST 2014


Hello All,

I have a unit here:

https://github.com/xrfang/pastats/blob/master/src/units/datalist.pas

which report this error:

/home/xrfang/git/pastats/src/units/datalist.pas(61,17) Warning: An
inherited method is hidden by "constructor TDataFrame.Create;"

However, the following code, which also define a new constructor without
using "overload", does NOT have such warning.

program Project1;
{$mode objfpc}{$H+}
type
  TBase = class
  public
    constructor Create(AName: string);
  end;
  TDerived = class(TBase)
  public
    constructor Create;
  end;

constructor TDerived.Create;
begin
  WriteLn('Creator of TDerived... anonymous');
end;

constructor TBase.Create(AName: string);
begin
  WriteLn('Creator of TBase: ', AName);
end;

var
  obj: TDerived;
begin
  obj := TDerived.Create;
end.

If I use reintroduce, I can suppress this warning. But my question is, why
is this warning NOT displayed in the above sample code? In general, shall I
use "reintroduce" keyword? Is it related to generics?

Thanks!

Xiangrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140504/b182916e/attachment.html>


More information about the fpc-pascal mailing list