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!
struct B : A { };works perfectly well.publicby default (it'sprivatefor classes).std::string name;. Even in C I would probably use a dynamically allocated chunk of memory instead of a fixed size array. How would you possibly account for Mr. Frued Von Bissmark III?