pascal 如何实现c 中的union 类型?(10分)

Q

qzq

Unregistered / Unconfirmed
GUEST, unregistred user!
不知有没有办法呢?
 
这个好像不太好办.
union类型常用于直接和系统底层打交道,而delphi对这个不擅长.
 
union并不好用,好象也没有太大必要,为什么要用这个东东呢?
 
Object Pascal中的变体记录类型,就相当于C中的Union类型,
请参见Delphi的帮助
 
类比一下:
c:
union{struct {handle hmem;
dword dwreserved[3];}block;
struct{dword dwcommittedsize;dword dwuncommittedsize;
lpvoid lpfirstblock;lpvoid lplastblock;}region;
};
delphi:
case integer of
0:(block:record
hmem:handle;
reserved:arrary[0..2] of dword;end);
1:(region:record
dwcommittedsize:dword;dwuncommittedsize:dword;
lplastblock:pointer;lpfirstblock:pointer;end);
 
可以, 没问题, 如果要详细解释看delphi4编程大全这本书, 解释得非常清楚.
我已经上传了. (http://www.gislab.ecnu.edu.cn/delphibbs/dispq.asp?LID=143386)
 
cytown: 我到你的下载地址下载了这本书,但是好像zip文件是坏的?你检查过吗?
 
:-( 我已经知道了, 而且已经重新上传了:)
 
多人接受答案了。
 
顶部