Re: storing related structs
- From: Chris Dollin <eh@xxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 30 Jun 2007 15:05:51 GMT
Grey Alien wrote:
Army1987 wrote:
"Grey Alien" <grey@xxxxxxxxxxxxx> ha scritto nel messaggioAh, I see. I understand now. Actually it won't be necessary since the
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.
structs themselves contain a 'type' enum
Well, you have to be /careful/, then: you can only reliably get
at that enum (IIRC) if it's either the first field in the structure
(A or B) or a member of that first field.
Safer, I would have said, to have it outside the union -- but
it depends on the /full details of the problem you're trying
to solve/, with which we have not been blessed.
--
Unshriven Hedgehog
"Our future looks secure, but it's all out of our hands"
- Magenta, /Man and Machine/
.
- Follow-Ups:
- Re: storing related structs
- From: Grey Alien
- Re: storing related structs
- References:
- storing related structs
- From: Gray Alien
- Re: storing related structs
- From: Army1987
- Re: storing related structs
- From: Grey Alien
- Re: storing related structs
- From: Army1987
- Re: storing related structs
- From: Grey Alien
- storing related structs
- Prev by Date: Re: storing related structs
- Next by Date: Re: Display C in HTML
- Previous by thread: Re: storing related structs
- Next by thread: Re: storing related structs
- Index(es):
Relevant Pages
|