1、没什么意思,语法要求。
2、个人喜好,随便了。
3、这个定义无法判断。如果想判断,应该这样定义:
TByteChar = record
MyType: Boolean;
case Boolean of
False: (rChar: Char);
True: (rByte: Byte);
end;
C中Union也是采用类似结构才能判断地。
2、个人喜好,随便了。
3、这个定义无法判断。如果想判断,应该这样定义:
TByteChar = record
MyType: Boolean;
case Boolean of
False: (rChar: Char);
True: (rByte: Byte);
end;
C中Union也是采用类似结构才能判断地。
这个记录相当于c里面的union 拿过来直接用就ok了
在程序中 如果你想把这个记录当Byte用 就可以直接当作Byte
如果想当Char用,就可以直接当作Char
vByteChar: TByteChar;
begin
vByteChar.MyByte := True; // Now you can decide to use rByte
vByteChar.rByte := 97;
ShowMessage(vByteChar.rChar);
end;
FirstName, LastName: string[40];
BirthDate: TDate;
case Citizen: Boolean of
True: (Birthplace: string[40]);
False: (Country: string[20];
EntryPort: string[20];
EntryDate, ExitDate: TDate);
end;当指定Country: string[20];
EntryPort: string[20];
EntryDate, ExitDate: TDate:的值时是否要指定:Citizen的值呢?
大家帮看看这个问题(100)?
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1126334