求助熟悉delphi的兄弟, Pascal 和C++的对应写法!
如下 pascal 语句
type
PPacket = ^TPacket;
TPacket = packed record
case Integer of
0: (b0, b1, b2, b3: Byte);
1: (i: Integer);
2: (a: array[0..3] of Byte);
3: (c: array[0..3] of Char);
end;
对应成如下c++,请问是否对?另外上面 Pascal 的case Integer of 是否对应C++的构造函数?
struct TPacket
{
Byte b0, b1, b2, b3;
int i;
Byte a[3];
char c[3];
};
type
PPacket = ^TPacket;
TPacket = packed record
case Integer of
0: (b0, b1, b2, b3: Byte);
1: (i: Integer);
2: (a: array[0..3] of Byte);
3: (c: array[0..3] of Char);
end;
===================================
typedef union{
struct{
unsigned char b0;
unsigned char b1;
unsigned char b2;
unsigned char b3;
};
struct{
int i;
};
struct{
unsigned char a[4];
};
struct{
char c[4];
};
}TPacket,*PPacket;