embeded anonymous structs and unions...

Eljay Love-Jensen eljay@adobe.com
Tue Mar 18 23:51:00 GMT 2003


Hi Gareth,

Try this...

class Blah {
public:
   double x,y,z;
   double& operator [] (int i) { return (&x)[i]; }
};

Note:  this is relying on the C++ behavior of laying out in memory the 
variables as given.  This is a typical (standard?) behavior of all the C++ 
compilers that I've used.

--Eljay



More information about the Gcc-help mailing list