Guest User

Untitled

a guest
Dec 15th, 2016
89
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program Project2;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. type
  9.   IService1 = interface
  10.     ['{7B5DAF28-5B13-4760-A3B3-29D73C1C0C7C}']
  11.   end;
  12.  
  13.   IService2 = interface
  14.     ['{D1623AFA-FAC2-4DF5-9E1D-48A1BF9B2D42}']
  15.   end;
  16.  
  17.   TSlave = class
  18.   public
  19.     procedure UseService(const Service1: IService1); overload;
  20.     procedure UseService(const Service2: IService2); overload;
  21.   end;
  22.  
  23.   TService1 = class(TInterfacedObject, IService1);
  24.   TService2 = class(TInterfacedObject, IService2);
  25.  
  26. procedure TSlave.UseService(const Service1: IService1);
  27. begin
  28. end;
  29.  
  30. procedure TSlave.UseService(const Service2: IService2);
  31. var
  32.   ServiceTemp: IService2;
  33. begin
  34.   ServiceTemp := Service2;
  35. end;
  36.  
  37. procedure TestSlave;
  38. var
  39.   Slave: TSlave;
  40. begin
  41.   Slave := TSlave.Create;
  42.   try
  43.     Slave.UseService(TService1.Create); // leaked
  44.     Slave.UseService(TService2.Create); // not leaked
  45.   finally
  46.     Slave.Free;
  47.   end;
  48. end;
  49.  
  50. begin
  51.   try
  52.     ReportMemoryLeaksOnShutdown := True;
  53.     TestSlave;
  54.     Readln;
  55.   except
  56.     on E: Exception do
  57.       Writeln(E.ClassName, ': ', E.Message);
  58.   end;
  59. end.
  60.  
  61. begin
  62.   try
  63.     { TODO -oUser -cConsole Main : Insert code here }
  64.   except
  65.     on E: Exception do
  66.       Writeln(E.ClassName, ': ', E.Message);
  67.   end;
  68. end.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×