|
µ¨¸¶´ç °ø½Ä ÀºÇà°èÁ |
ÇϳªÀºÇà 227-910235-83607 |
¿¹±ÝÁÖ ÀÌ»ó±¹(¿î¿µÁø) |
|
|
|
|
|
|
|
|
|
|
°ÁÂ, ÆÁ, Á¤º¸ |
°ÁÂ, ÆÁ, Á¤º¸ ÀÔ´Ï´Ù. |
|
|
|
°£´ÜÇÑ Guard (°´Ã¼ ÀÚµ¿ Free) |
ÇÁ¸®¸Ç
(¼Õ´Ô)
2005-10-14 ¿ÀÈÄ 3:26:47
Ä«Å×°í¸®:
°ÁÂ
4417ȸ Á¶È¸
µî·ÏµÈ ÆÄÀÏÀÌ ¾ø½À´Ï´Ù.
|
|
|
unit Guards;
interface
function Guard(out Reference; Instance: TObject): IUnknown;
implementation
type TGuardObject = class(TInterfacedObject) private FInstance: TObject; public constructor Create(Instance: TObject); destructor Destroy; override; end;
{ TGuardObject }
constructor TGuardObject.Create(Instance: TObject); begin FInstance:= Instance; end;
destructor TGuardObject.Destroy; begin FInstance.Free; inherited; end;
function Guard(out Reference; Instance: TObject): IUnknown; begin Result:= TGuardObject.Create(Instance); TObject(Reference):= Instance; end;
end.
»ç¿ë¿¹:
procedure TForm1.Button1Click(Sender: TObject); var List: TStringList; begin Guard(List, TStringList.Create); List.Add('1234'); end;
Çؼ³:
JCLÀÇ Guard¿Í °°Àº°ÍÀε¥ Á»´õ °£°áÇÏ°Ô ¸¸µç°ÍÀÔ´Ï´Ù. ¿ø¸®´Â °£´ÜÇÕ´Ï´Ù. Guard´Â IUnknownÀ» ¹ÝȯÇϴµ¥ ÀÌ°ÍÀ» ÀϺη¯ ¹ÞÁö ¾Ê´Â°ÍÀÌÁÒ. ±×·¯¸é IUnknownÀº Àӽú¯¼ö¿¡ ÀúÀåµË´Ï´Ù. Àӽú¯¼ö´Â Áö¿ªº¯¼ö¿Í ¸¶Âù°¡Áö·Î ÇÁ·Î½ÃÁ®°¡ Á¾·áÇÒ¶§±îÁö À¯ÁöµË´Ï´Ù. Àӽú¯¼ö°¡ IUnknown À̹ǷΠÁ¾·áÇÒ¶§ ÀÚµ¿ FreeµÇ°í À̶§ ³Ñ°ÜÁá´ø °´Ã¼µµ °°ÀÌ Free µÇ´Â°ÍÀÔ´Ï´Ù.
|
|
|
|
|
|
|
|
|