Yes, it works. But in this case, I don't understand the sense of the pattern.

If I need to do "TAnimalFactory.create(atDog) as Tdog", perhaps, it
would be better not to use a factory, doing simply "TDog.create".

I don't understand if I have implemented the pattern wrongly or if
this pattern, becose of the strong typing of the language, does not
make sense in Pascal.

2015-11-27 19:30 GMT-02:00, Mattias Gaertner <nc-gaert...@netcologne.de>:
>
> One solution:
>
> var
>   animal: TDog;
> BEGIN
>   animal := TAnimalFactory.create(atDog) as TDog;
>   try
>     animal.bark;
>   finally
>     animal.free;
>   end;
> END.
>
>
> Mattias
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>


-- 
Luciano de Souza
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to