This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

embeded anonymous structs and unions...


Hi,

I was wondering if there was someway to do the equivelent of what the following code looks like...

class Blah
{
   union
   {
       double coords[3];
       struct
       {
           double x, y, z;
       };
   };
}

that is, put an anonymous struct inside an anonymous union...
I tried the above with g++ 3.4 20030314 - with no luck...

the above combined with an operator[] returning a reference to coords elements
would allow
Blah c;
c.x = 1;
c.y = 1;
c.z = 1;
for (int i=0; i<3; i++)
std::cout << c[i] << std::endl;


to function.

Any clues?

Thanks,
Gareth

_________________________________________________________________
MSN Instant Messenger now available on Australian mobile phones.?Go to http://ninemsn.com.au/mobilecentral/hotmail_messenger.asp



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]