标签:
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.
标签:
原文地址:http://www.cnblogs.com/wucg/p/4205733.html