Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Union member in a struct

Status
Not open for further replies.

jmodo

Programmer
Aug 2, 2006
43
0
0
US
I have the following code which doesn't compile(solaris). "The Union is not accessible from the struct". When I move the Union to be public, it compiles. Can anyone explain this? I'd like to keep both private if possible. Thanks!

private:
Union MyUnion
{
UObject* uobject;
//other variables here
};
struct MyStruct
{
MyUnion myUnion; //Doesn't compile here
//other variables here
};
 
The union keyword, not Union ;-)
----!----
 
I am using the keyword union. Sorry that 'Union' was a typo.
 
The problem is that other than within the class, the contents of myUnion cannot be accessed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top