[fpc-devel] FPC 2.0 and Delphi difference in scope of protected class members

David Butler david at e.co.za
Tue Jun 7 15:42:30 CEST 2005


Hi

In Delphi the protected members are "visible anywhere in the module
where its class is declared and from any descendant class, regardless
of the module where the descendant class appears."

It seems that FPC 2.0 doesn't support that second part: "regardless of
the module where the descendant class appears".

For example, in this code, FPC does not see the "inherited
TestProc(C)". It does see it if the base class is moved into the same
file.

Regards
David



<file fpctest.pas>

Program Test1;

uses
  fpctestunit1;

type
  TestC = class(TestB)
  public
    procedure TestProc; override;
    procedure TestProc(const C: Integer); override;
  end;

var
  X : TestC;

procedure TestC.TestProc;
begin
  inherited TestProc;
end;

procedure TestC.TestProc(const C: Integer);
begin
  inherited TestProc(C);
end;

begin
  X := TestC.Create;
  X.TestProc(10);
  X.Free;
end.



<file fpctestunit1.pas>

unit fpctestunit1;

interface

type
  TestA = class
  protected
    procedure TestProc; overload; virtual;
    procedure TestProc(const C: Integer); overload; virtual;
  end;
  TestB = class(TestA)
  public
    procedure TestProc; override;
  end;

implementation

procedure TestA.TestProc;
begin
end;

procedure TestA.TestProc(const C: Integer);
begin
end;

procedure TestB.TestProc;
begin
end;

end.





More information about the fpc-devel mailing list