Union within structures 
Author Message
 Union within structures

:I understood that if i declare a union within a struct - I can access
:the union fields without directly specifying the union name.
===========
You understood incorrectly.
===========
:
:For example:
:
:if I have declared:
:
:typedef struct {
:  enum _nodeType {leaf=1,interior} nodeType;
:  union {
:    int leaf;
:    char interior;
:  } data;
:} two3Node;
:
:two3Node node;
:
:then I should be able to access the leaf field by "node.leaf" (Ofcorse
:that "node.data.leaf" would work, but that is what I want to avoid...).
:
:Is it true? how exactly can I do it?
:thanks in advance.
:



Wed, 29 Nov 2000 03:00:00 GMT  
 Union within structures



Quote:
>I understood that if i declare a union within a struct - I can access
>the union fields without directly specifying the union name.

No, C doesn't support anonymous unions.

--
-----------------------------------------


-----------------------------------------



Wed, 29 Nov 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. help: unnamed unions within structures

2. unions within structures

3. structures within structures

4. Q about structures within structures

5. Initialising Structure Within Structure...How?!

6. structuresand arrays within unions

7. Question regarding unions and structures

8. fread w/ Union structures

9. Structures vs. Unions

10. Initialising Union members of Structures

11. Bit-fields, unions and structures...

12. structure, union & enumeration tags

 

 
Powered by phpBB® Forum Software