Advertisement
Guest User

Out parameter

a guest
Jul 10th, 2014
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.88 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     procedure Button1Click(Sender: TObject);
  13.   private
  14.     { Private declarations }
  15.   public
  16.     { Public declarations }
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. implementation
  23.  
  24. {$R *.dfm}
  25.  
  26. type
  27.   TFoo = class
  28.   private
  29.     FBar: string;
  30.   public
  31.     property Bar: string read FBar write FBar;
  32.   end;
  33.  
  34. procedure DoSomething(const AString: string; out AFoo: TFoo);
  35. begin
  36.   AFoo.Bar := AFoo.Bar + AString;
  37. end;
  38.  
  39. procedure TForm1.Button1Click(Sender: TObject);
  40. var
  41.   LFoo: TFoo;
  42. begin
  43.   LFoo := TFoo.Create();
  44.   try
  45.     LFoo.Bar := 'Hello World';
  46. //    ShowMessage(LFoo.Bar);
  47.     DoSomething('a', LFoo);
  48. //    ShowMessage(LFoo.Bar);
  49.   finally
  50.     LFoo.Free();
  51.   end;
  52. end;
  53.  
  54. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement