[fpc-pascal] double dispatch

Jorge Aldo G. de F. Junior jagfj80 at gmail.com
Fri Mar 18 22:47:35 CET 2011


Can FPC deal with double-dispatch ?

Say you have an object defined as :

Type
TMyObject = Class
Public
Procedure DoSomething(Const aObject : TObject); Virtual;
End;

TMyParameterObject = Class
Public
End;

TMyOtherParameterObject = Class
Public
End;

Can you do something like :

Type
TMyOtherObject = Class(TMyObject)
Public
Procedure DoSomething(Const aObject : TMyParamaterObject); Override; Overload;
Procedure DoSomething(Const aObject : TMyOtherParameterObject);
Override; Overload;
End;

And have the run-time choose the correct implementation to call by
looking at the object type ?



More information about the fpc-pascal mailing list