아래에 보인것과 같이 Pascal에서의 union은 case문을 사용해서 구현됩니다.
Record help를 보시면 "Variant parts in records"라는 부분이 있는데요 그것이
case ( union )을 설명하는 부분입니다.
Help를 보시구요 이해가 안가거나... 기타등등(ㅠㅠa) 모르는것이 있으시면 다시
질문하십시요.
procedure UnionInPascal;
type
TestRecord = record
case Boolean of
TRUE : ( A : LongWord );
FALSE : ( Byte1, Byte2, Byte3, Byte4 : Char );
end;
var
lrRcd : TestRecord;
begin
lrRcd.Byte1 := #1;
lrRcd.Byte2 := #0;
lrRcd.Byte3 := #0;
lrRcd.Byte4 := #0;
Application.MessageBox( PChar( IntToStr( lrRcd.A ) ), '', MB_OK );
end;
|