I have the following packet layout:
struct PacketLayout
{
int GateCode;
BYTE StringLen;
char String[StringLen];
BYTE ServerStatus;
BYTE ServerStorage;
BYTE ServerNumber;
}
The class is this:
class ServerInfo
{
short PacketSize; //Size of the whole packet
BYTE TotalServers; //total of PacketLayout structs
PacketLayout Server[TotalServers];
int GlobalSecCode;
short EncryptedPacketSize; //Same as the first member, just xored
}
So the problem i have is making an variable size array inside an class or an struct which size depends of the last member pointed by BYTE StringLen (for struct) and BYTE TotalServers (for the class).
I don't know what is the solution to this, maybe implement a template?, if that's so can i see an example (i am not familiar with templates yet) also i want to reference my member names without calculating the pointer position by myself (as i am currently doing now).
Thanks.