procedure TForm4.FormCreate(Sender: TObject); var a, b: string; begin a := 'Test'; b := a; ShowMessage(BoolToStr(pointer(a) = pointer(b), true)); end;
The result is True , so yes, a and b indicate the same data.
note that
procedure TForm4.FormCreate(Sender: TObject); var a, b: string; begin a := 'Test'; b := a; b := 'Test2'; ShowMessage(BoolToStr(pointer(a) = pointer(b), true)); end;
displays False , as it should be.
Also note that
procedure TForm4.FormCreate(Sender: TObject); var a, b: string; begin a := 'Test'; b := a; ShowMessage(BoolToStr(@a = @b, true)); end;
also displays False , because a and b are different string (pointer) variables, so in some place in memory ( @a ) there is data address a , and somewhere else ( @b ) is data address b . The first example shows that these two places in memory contain the same address, that is, a and b contain the same data.
source share