title: "Extend" Struct in C++
body: <p>I say "extend" because after a google search I'm not sure that is the proper name for what I'm trying to accomplish.</p>
  
  <p>Basically what I'm trying to do is create a struct (just for fun, let's also include classes in this question) with some blank variables in it, then make another struct or class that carries on where the parent left off, filling in those variables.</p>
  
  <p>So something like this:</p>
  
  <pre><code>struct parent{
  
      int foo;
      int bar;
  };
  
  struct daughter : parent{
      foo=1;
      bar=3;
  };
  
  struct son : parent {
      foo=10;
      bar=20;
  
      int foobar;
  };
  </code></pre>
  
  <p>and later on, I might need to branch out this tree further:</p>
  
  <pre><code>struct grandson : son {
      foo=50;
      bar=900;
      foobar=10000;
  };
  </code></pre>
  
  <p>What would be the correct way to go about this?</p>
  
  <p>EDIT:</p>
  
  <p>@Everyone:
  So, I can explain what I'm trying to do, and you can counter it with better ways, and who knows, maybe those ways are much better. However, first, right off the bat, I'm just curious if what I'm asking is possible...</p>
  
  <p>And something I left out:</p>
  
  <pre><code>struct parent{
      int foo;
      int bar;
      int foobar;
  
      int add(int x, int y){
          return x+y;
      };
  
  struct son : parent {
      foo=12;
      bar=13;
      foobar=add(foo,bar);
  }
  </code></pre>