embeded anonymous structs and unions...

Gareth Pearce tilps@hotmail.com
Tue Mar 18 01:45:00 GMT 2003


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



More information about the Gcc-help mailing list