TGridRect对象怎么方便地初始化
TGridRect对象如何方便地初始化声明如下:struct DECLSPEC_DRECORD TGridRect{#pragma pack(push,1)union{s
TGridRect对象如何方便地初始化
声明如下:
struct DECLSPEC_DRECORD TGridRect
{
#pragma pack(push,1)
union
{
struct
{
TGridCoord TopLeft;
TGridCoord BottomRight;
};
struct
{
int Left;
int Top;
int Right;
int Bottom;
};
};
#pragma pack(pop)
};
这种union和struct嵌套的怪胎如何像普通struct一样用[struct名](成员1,成员2, ...)的形式声明一个对象并初始化呢?
要不然只能用[struct名].[成员名1]=...这种形式了,好麻烦。
struct union 声明
[解决办法]TGridRect gr = { { 100, 200 }, { 300, 400 } };
那么,Left = 100, Top = 200, Right = 300, Bottom = 400