Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-06

FPC 2.0 and Delphi difference in scope of protected class members

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

David Butler

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.

Reply by email