program Day4; {$APPTYPE CONSOLE} uses SysUtils, Util in ‘Util.pas‘; type TPerson = packed record ID : integer; case IsFullJob : Boolean of true: ( Year : Cardinal; ); false:( Hour : word; ); end; var s : string; ss : ShortString; p : TPerson; begin Writeln(‘sizeof integer:‘,sizeof(integer)); Writeln(‘sizeof cardinal:‘,sizeof(cardinal)); Writeln(‘sizeof word:‘,sizeof(word)); Writeln(‘sizeof boolean:‘,sizeof(boolean)); Writeln(‘sizeof TPERSON:‘,sizeof(Tperson)); p.ID := 110; p.Year := $80000001; //$8 = 1000 b Writeln(‘p.year:‘,p.year); Writeln(‘p.hour:‘,p.hour); p.IsFullJob := true; Writeln(‘p.IsFullJob:‘,p.IsFullJob); readln; end.
类似C中的联合体union.