向高手请教, DELPHI变体取值不正确,是不是稳定性有问题
定义了一个变体,但取其中的前五个值都是 -1, 明显是错误的, 难道是传说中的 DELPHI 不稳定现象吗?程序代码:
testrec = packed record case Integer of 0: (shi:Shortint); 1: (b:Byte); 2: (smi: Smallint); 3: (w: WORD); 4: (i: Integer); 5: (dw:DWORD); 6: (buff : array[0..3] of Byte); end; procedure TForm1.Button1Click(Sender: TObject); var a : testrec; begin a.i := -1; ShowMessage(IntToStr(a.shi));// -1 ShowMessage(IntToStr(a.b));// -1 ShowMessage(IntToStr(a.smi));// -1 ShowMessage(IntToStr(a.w));// -1 ShowMessage(IntToStr(a.i));// -1 ShowMessage(IntToStr(a.dw));// 4294967295 end;