Talking about structs, is it possible to just copy a struct‘s fields to another struct without explicitly calling the type field name?
Let me show you an example:
struct StructA
{
char Name[20];
int Age;
};
struct StructB
{
StructA FieldStructA;
int SomeOtherDeclarations;
// ...
};
So, I could access the StructA fields on StructB doing this:
StructB strB;
strB.FieldStructA.Name[0] = 0;
What I want to do is access the StructA fields through StructB without accessing the data field on StructB. Something like inheritance between classes. Like this:
StructB strB;
strB.Name[0] = 0;
I want to inherit StructA fields on StructB. I know that I could do that with classes, but I have to use struct for some reasons (interop, specific use of stack and so on).
Thanks for your time!
If you are using gcc, try making it an anonymous member:
http://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html