下面是Delphi对TRect的定义
type
TPoint = record
X: Longint;
Y: Longint;
end;TRect = record
case Integer of
0: (Left, Top, Right, Bottom: Integer);
1: (TopLeft, BottomRight: TPoint);
end;
我的问题是:
case Integer of 在上面语句中是什么意思? 使用TRect的时候怎么用?
type
TPoint = record
X: Longint;
Y: Longint;
end;TRect = record
case Integer of
0: (Left, Top, Right, Bottom: Integer);
1: (TopLeft, BottomRight: TPoint);
end;
我的问题是:
case Integer of 在上面语句中是什么意思? 使用TRect的时候怎么用?
struct {
int Left,Top,Right,Bottom;
}Rec1;
struct {
POINTAPI TopLeft,BottomRight;
}Rec2;
}
TRect = record
case Integer of
0: (Left, Top, Right, Bottom: Integer);
1: (TopLeft, BottomRight: TPoint);
end;
中,Integer是数据类型,0和1是它的两个值,这个声明的意思是说内存中有一块区域存放了四个整型值,你可以用TRect.Left,TRect.Top...来访问,也可以用TRect.TopLeft来访问。用不到0和1这两个值的,他们仅仅为可读性而存在。
case Boolean of
False:(...);
True:(...);是吗?