[fpc-pascal] Access inherited^2

Vincent Snijders vsnijders at quicknet.nl
Sun Aug 10 10:01:11 CEST 2008


Johann Glaser schreef:
> Hi!
> 
> How can I access an inherited inherited method which was overloaded?

Try the following, mark the constructors as overloaded:
> 
> ====== Example: ======
> 
> {$mode objfpc}{$H+}
> Program TestInherited;
> Uses Classes, SysUtils;
> 
> Type
>   TFirst = class
     Constructor Create(A,B,C:Integer); overload;
>   End;
>   TSecond = class(TFirst)
     Constructor Create(A,B:Integer); overload;
>   End;
>   TThird = class(TSecond)
      Constructor Create(A,B:Integer); overload;
>   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?

The constructor with 3 parameters is hidden.

Vincent



More information about the fpc-pascal mailing list