title: C++: Construct subclass from base class instance?
body: <p>I have three structs, one of which inherits from the other two:</p>
  
  <pre><code>typedef struct _abc
  {
      int A;
      int B; 
      int C;
  } ABC;
  
  typedef struct _def
  {
      int D;
      int E;
      int F;
  } DEF;
  
  typedef struct _abcdef : ABC, DEF { } ABCDEF;
  </code></pre>
  
  <p>(I want the third struct to contain all the members of the first two. Is there a better way to do it?)</p>
  
  <p>Now, I have fully populated instances of <code>ABC</code> and <code>DEF</code>, and I want to make a new <code>ABCDEF</code> instance:</p>
  
  <pre><code>int main()
  {
      ABC abc;
      abc.B = 2;
      abc.C = 1;
      abc.A = 10;
  
      DEF def;
      def.D = 32;
      def.E = 31;
      def.F = 90;
  
      // make a new ABCDEF with all the values of abc and def
  }
  </code></pre>
  
  <p>What is the best way to create the <code>ABCDEF</code>? I could do this, but it kinda sucks:</p>
  
  <pre><code>ABCDEF abcdef;
  abcdef.A = abc.A;
  abcdef.B = abc.B;
  abcdef.C = abc.C;
  abcdef.D = def.D;
  abcdef.E = def.E;
  abcdef.F = def.F;
  </code></pre>
  
  <p>The above is coupled to the members of the structs, and is messy if many members are added.</p>