Not sure about your question exactly, but everything in Java is passed by
reference, and all objects are covariant, so you shouldn't need to do
anything.

On Wed, Jun 8, 2016 at 6:17 PM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> Hi,
>
> I know this is not a Java forum, but thought maybe somebody here with
> Object Pascal and Java knowledge could help (seeing that Java-only
> developers might not know what I'm talking about).
>
> Does Java have an equivalent feature of a Object Pascal language's Class
> Reference.
>
> For Example:
> I want to write Java code that does similar to my Object Pascal code
> shown below:
>
> TVisClassRef = class of TVisitor ;
>
> procedure ExecuteVisitor(const pData: TVisited; const pVisClass:
> TVisClassRef);
> var
>   lVisitor: TVisitor;
> begin
>   lVisitor := pVisClass.Create;  // <<-- Important Part
>   try
>     pData.Iterate(lVisitor);
>   finally
>     lVisitor.Free;
>   end;
> end;
>
> This procedure takes care of the tedious business of creating the
> visitor, calling iterate, then freeing the visitor when done. I can pass
> in various class references as the second argument (all descendants of
> TVisitor), and different class instances will be created and used as
> needed.
>
> I would love to know how I could do this in Java.
>
> Regards,
>   Graeme
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>



-- 
Ryan
[ERROR]: Your autotools build scripts are 200 lines longer than your
program. Something’s wrong.
http://kirbyfan64.github.io/
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to