title: C++ can't access child property from parent
body: <p>Can anybody explain why <code>Driver</code> <code>init()</code> method is unable to print <code>name</code> property overridden in child?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  class Driver {
  public:
      std::string name = "Unknown";
  
      void init() {
          std::cout &lt;&lt; name &lt;&lt; std::endl;
      }
  };
  
  // need public here to inherit init()
  class SpecificDriver : public Driver {
  public:
      std::string name = "Specific";
  
  };
  
  int main() {
      Driver d;
      SpecificDriver sd;
  
      // this gives Unknown Unknown =/
      d.init();
      sd.init();
  }
  </code></pre>
  
  <p>This gives:</p>
  
  <pre><code>Unknown
  Unknown
  </code></pre>
  
  <p>And should be:</p>
  
  <pre><code>Unknown
  Specific
  </code></pre>
  
  <p><a href="http://coliru.stacked-crooked.com/a/ae5380798d9a4731" rel="nofollow"><kbd>Live Demo</kbd></a></p>