[fpc-devel] Which of them are right (Delphi or FPC)
Michael Van Canneyt
michael at freepascal.org
Tue Apr 18 09:36:15 CEST 2006
On Tue, 18 Apr 2006, Amir Aavani wrote:
> I developed a project in lazarus (FPC) and now when I try to run it in
> Delphi, it acts incorrect!
>
> I have a class TObjectCollection which is a collection of TObject:
> TObjectCollection= class (TObject)
> FMembers: array of TObject;
> ...
> ...
> public
> property Member [Index: Integer]: TObject read GetMember;
> ...
> procedure Add (ANewMember: TObject);
> ...
> end;
>
> And A TObject1Collection which is like this:
> TObject1Collection= class (TObjectCollection)
> function GetMember: TObject1;
> ...
> ...
> public
> property Member [Index: Integer]: TObject1 read GetMember;
> ...
> procedure Add (ANewMember: TObject1);
> ...
> end;
>
> procedure TObject1Collection.Add (ANewMember: TObject1);
> begin
> (Self AS TObjectCollection).Add (ANewMember AS TObject);
> end;
>
> procedure TObject1Collection.GetMember: TObject1;
> begin
> Result:= (Self AS TObjectCollection).Member AS TObject1;end;
> end;
>
> The code works correctly in lazarus, but in Delphi, the procedure
> TObject1Collection.Add call itself instead of TObjectCollection.Add. I
> changed the code like this:
> SelfAsTObjectCollection:= Self As TObjectCollection;
> SelfAsTObjectCollection.Add (ANewMember);
> and the problem solved.
> I want to know, which of us (me, Delphi, Freepascal) is wrong.
For delphi you must use the 'overload' directive.
Michael.
More information about the fpc-devel
mailing list