procedure TForm1.Button4Click(Sender: TObject); var A, B, C: TButton; begin A := TButton.Create(Self); B := A; if A = B then ShowMessage('=') else ShowMessage('<>'); A.Free; B := nil; A := nil; end;
procedure TForm1.Button4Click(Sender: TObject); var A, B, C: TButton; begin A := TButton.Create(Self); B := A; if A = B then ShowMessage('=') else ShowMessage('<>'); A.Free; B := nil; A := nil; end;
好象不是吧。 A := TButton.Create(Self); B := A; 此时,应该是A,B同时指向原A的对象。我想问的是,给我:A,B两个指针(假设已经知道他们都针对对象),我想判断:A,B背后的对象是否是同一个。如何操作?
var
A, B, C: TButton;
begin
A := TButton.Create(Self);
B := A;
if A = B then
ShowMessage('=')
else
ShowMessage('<>');
A.Free;
B := nil;
A := nil;
end;
var
A, B, C: TButton;
begin
A := TButton.Create(Self);
B := A;
if A = B then
ShowMessage('=')
else
ShowMessage('<>');
A.Free;
B := nil;
A := nil;
end;
B := A;
此时,应该是A,B同时指向原A的对象。我想问的是,给我:A,B两个指针(假设已经知道他们都针对对象),我想判断:A,B背后的对象是否是同一个。如何操作?
...
else
...是这意思?