Free
메서드를 호출 한 후 객체가 nil
이 아닌 이유가 궁금합니다. 내가 예를 들어 다음 클래스를 무엇을 의미
: 객체를 해제 한 후 nil
하지 않고 어떻게 a := nil
를 사용하지 않고 소멸자 후 nil
을 할 a
을 할 이유TObject 및 NIL의 소멸자 클래스 Delphi
type Ta = class(TObject)
public
i: integer;
destructor Destroy; override;
end;
destructor Ta.Destroy;
begin
inherited;
end;
procedure Form1.Button1;
var a: Ta;
begin
a := Ta.Create;
a.Free;
if a = nil then
button1.Caption := 'is assigned'
else
button1.caption := 'is not assigned';
end;
내 질문은?
개체를 해제해도 개체가 0으로 설정되지 않습니다. FreeAndNil (a)를 사용하십시오 – kobik
그리고 당신은 소멸자로 만들 수 없습니까? – user558126
아니, 할 수 없습니다. – kobik