SHARE
TWEET

http://stackoverflow.com/questions/17652922/automatically-fr

a guest Jul 15th, 2013 46 Never
  1. type myClass = class(TMyInterfacedObject)
  2.          public
  3.             destructor Destroy; override;
  4.      end;
  5.  
  6. destructor myClass.Destroy;
  7. begin
  8.    do cleanup
  9. end;
  10.  
  11. procedure MyProcedure;
  12. var IGuard: iInterface;
  13. begin
  14.    ...
  15.    IGuard := myClass.Create(acquire resources);
  16. ....
  17. end;  // IGuard is automatically decremented here and myClass destructor is called
RAW Paste Data
Top