constructors in unions
Andrew Haley
aph@redhat.com
Thu Dec 4 19:09:00 GMT 2003
Corn Hulio writes:
> Hello,
>
> why isn't the following contruct possible?
>
> union
> {
> Vector<float,3> pos;
>
> struct
> {
> float x, y, z;
> };
>
> float p[3];
> };
>
> GCC gives me this error:
> member `Vector<float, 3> <anonymous union>::pos' with constructor not
> allowed in union
>
> I guess in theory there should be no reason to disallow a member with
> constructor in a union (as long as there is not more than 1 constructor).
12.1, Para 12, Constructors: A union member shall not be of a class
type (or array thereof) that has a non-trivial constructor.
More information about the Gcc
mailing list