title: Why an union wont allow its elements to have an user-defined constructor?
body: <p>How can I make this second struct work, when the first struct has a constructor?
  I get error:</p>
  
  <pre><code>error C2620: member 'test::teststruct::pos' of union 'test::teststruct::&lt;unnamed-tag&gt;' has user-defined constructor or non-trivial default constructor
  </code></pre>
  
  <p>The code:</p>
  
  <pre><code>struct xyz {
      Uint8 x, y, z, w;
      xyz(Uint8 x, Uint8 y, Uint8 z) : x(x), y(y), z(z) {}
  };
  struct teststruct {
      union {
          Uint32 value;
          xyz pos; // error at this line.
      };
  };
  </code></pre>
  
  <p>I could use a function to initialize the xyz struct, but wouldn't it be a lot slower? Not to mention: I have tons of structs I need to create own function with a prefix like init_xyz() or etc, which isn't nice. Is there any other way going around this problem?</p>