I am dealing with a struct mf fixed arrays of char, but the size and placement of some of these members depend on other members. so I want to use __declspec(property) to dynamically retrieve these 'variable' members
so Ideally it would look something like this:
struct tVariableRecord
{
char cRecordType;
union
{
struct
{
char cRecordType1_Field1[4];
char cRecordType1_Filler[6];
char cRecordType1_Field2[6];
char cCRLF[2];
};
struct
{
char cRecordType2_Field1[6];
char cRecordType2_Field2[6];
char cCRLF[2];
};
}
__declspec(property(get=get_Field2)) char cField2[6];
char [6]&get_Field2()
{
static char cBadField2[6] = { '#', '#', '#', '#', '#', '#' };
switch (cRecordType)
{
case '1':
return cRecordType1_Field2;
break;
case '2':
return cRecordType2_Field2;
break;
default:
throw(unknownRecordType);
return cBadField2;
break;
}
}
};
I know the above won't work, but is there a way to do the same thing?