question about anonymous union usage

Jeffrey Holle jeff.holle@verizon.net
Mon Aug 9 22:54:00 GMT 2004


I'm using g++ v3.4.1.

I'm considering using an anonymous union in the following fashion:

   class SomeClass
   {
     ....
   private:
     bool isPseudo_;
     union {
       LayoutVertex *layoutVertex_;
       PseudoVertex *pseudoVertex_;
     };
   }

Both LayoutVertex and PseudoVertex have the same methods.

Only in the constructors of SomeClass will I have to code in a way that 
differenciates between layoutVertex_ and psuedoVertex_.

My question is can I safely use layoutVertex_ elsewhere even if its 
initialized with a PsuedoVertex object?



More information about the Gcc-help mailing list