[fpc-pascal] Access inherited^2

Johann Glaser Johann.Glaser at gmx.at
Sun Aug 3 18:04:29 CEST 2008


Hi!

How can I access an inherited inherited method which was overloaded?

====== Example: ======

{$mode objfpc}{$H+}
Program TestInherited;
Uses Classes, SysUtils;

Type
  TFirst = class
    Constructor Create(A,B,C:Integer);
  End;
  TSecond = class(TFirst)
    Constructor Create(A,B:Integer);
  End;
  TThird = class(TSecond)
    Constructor Create(A,B:Integer);
  End;

Constructor TFirst.Create(A, B, C: Integer);
Begin
  { ... }
End;

Constructor TSecond.Create(A, B: Integer);
Begin
  inherited Create(A,B,0);
End;

Constructor TThird.Create(A, B: Integer);
Begin
  inherited Create(A,B,0);   { <-- Error: Wrong number of parameters specified for call to "Create" }
End;

Begin

End.

===================================

The compiler complains in TThird.Create that the call to the inherited
method doesn't work. Removing the word "inherited" doesn't help.

What happened to the method with 3 parameters? Why is there an error
message? How can I access it?

Thanks
  Hansi





More information about the fpc-pascal mailing list