Re: storing related structs
- From: Grey Alien <grey@xxxxxxxxxxxxx>
- Date: Sat, 30 Jun 2007 14:00:09 +0100
Army1987 wrote:
"Grey Alien" <grey@xxxxxxxxxxxxx> ha scritto nel messaggio news:Z7OdnWRcAeZVoxvbnZ2dnUVZ8vidnZ2d@xxxxxxxxx<snip>
</snip>
Thanks - I forgot about unions ! (don't use them that much). Yes this soln will suffice for what I want to do.Is there a soln to this problem ?
struct C {
unsigned id;
char name; /* do you mean *name, or name[LARGE_ENOUGH]? */
enum { strA, strB } type;
union {
struct A str_A;
struct B str_B;
} the_struct;
};
A union is like a struct, but can only hold an element at a time.
You access members of unions like members of struct. For example,
in the case above to access the double of a struct B in a struct C,
you'll have to use mystructC.the_struct.str_B.z
Or try to find a better way to do what you're trying to do.
.
- References:
- storing related structs
- From: Gray Alien
- Re: storing related structs
- From: Army1987
- storing related structs
- Prev by Date: Re: storing related structs
- Next by Date: Re: storing related structs
- Previous by thread: Re: storing related structs
- Next by thread: Re: storing related structs
- Index(es):
Relevant Pages
|