[fpc-pascal] Implementing Factory Method with Pascal

Anthony Walter sysrpl at gmail.com
Sat Nov 28 01:16:34 CET 2015


type
  IBarkable = interface(IInterface)
  ['{B241068F-2ED9-43C7-066B-778B94CB58F9}']
    procedure Bark;
  end;

  TAnimal = class(IInterface)
  end;

  TDog = class(TAnimal, IBarkable)
  public
    procedure Live; override;
    procedure Bark;
  end;

and later ...

if Animal is IBarkable then (Animal as IBarkable).Bark;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20151127/db241996/attachment.html>


More information about the fpc-pascal mailing list