Re: Two questions about the following lines of code
- From: Justin Spahr-Summers <Justin.SpahrSummers@xxxxxxxxx>
- Date: Wed, 22 Aug 2007 23:21:02 -0700
On Aug 22, 8:39 pm, Chad <cdal...@xxxxxxxxx> wrote:
On Aug 22, 6:12 pm, pete <pfil...@xxxxxxxxxxxxxx> wrote:
You can read the tag to see what type of data is in the union.
Okay, I really don't see how it reads the tag to see what type of data
is in the union. I'm suspecting I'm going to have to break out the
debugger and step through the code to see what you are talking about.
Are you perhaps confused by the enumeration? An enumeration defines
integer constants by the names you provide between the braces (in this
case, DAYS and HOURSMINUTES, corresponding to 0 and 1, respectively,
although more are allowed). The code that "sets" the type of the
structure assigns one of these symbols (DAYS or HOURSMINUTES) to the
"tag" field and only modifies the intended field of the union. The
code that has to determine the value of the structure reads the "tag"
field and sees which enumeration value it contains (again, DAYS or
HOURSMINUTES) and then makes sure to read only the field of the union
that was last written.
.
- References:
- Prev by Date: Re: Comparing singed to unsinged warning
- Next by Date: Re: macros
- Previous by thread: Re: Two questions about the following lines of code
- Next by thread: Re: Two questions about the following lines of code
- Index(es):
Relevant Pages
|