Anonymous unions and the copy constructor

Started by
3 comments, last by ToastFlambe 18 years, 1 month ago
Simple quick question. I'm revamping my Vector class and put in an anonymous union like this:

union
{
    float index[2];
    float x, y;
};
Question is do I need a copy constructor still? Before I just had the "index" array and needed one but what happens now that its a union?
Advertisement
No, you do not. It'll get copied just fine.

Your original method should have copied automatically as well, if all it had was a raw array.

CM
An anonymous union inside a struct is illegal. The union needs to be named.

Oh Fruny, where art though, with your crazy static member pointers?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Never fear, Fruny is here.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Wow, that would take some serious code-fu to come up with that. Thanks!

This topic is closed to new replies.

Advertisement