Re: storing related structs





Army1987 wrote:

"Grey Alien" <grey@xxxxxxxxxxxxx> ha scritto nel messaggio news:ifOdnb3U0drIyBvbnZ2dnUVZ8qSnnZ2d@xxxxxxxxx


Army1987 wrote:

<snip></snip>

struct C {
unsigned id;
char name; /* do you mean *name, or name[LARGE_ENOUGH]? */
enum { strA, strB } type;

Why have you declared an enum here? ^ (can't see why this is needed)


The point is, you have to somehow keep track of wheter the union
contains a struct A or a struct B.

Ah, I see. I understand now. Actually it won't be necessary since the structs themselves contain a 'type' enum


union {
struct A str_A;
struct B str_B;
} the_struct;
};




.



Relevant Pages