title: C++ change base's member variable and print it from derived class
body: <p>The idea is:</p>
  <blockquote>
  <p>I've 2 classes, one named <code>Print</code> with only one method called <code>printName</code>, and other class named <code>Human</code> with variable <code>name</code>. I want <code>printName</code> to print whatever the <code>name</code> variable in the <code>Human</code> class is.</p>
  </blockquote>
  <p>Example:</p>
  <pre class="lang-cpp prettyprint-override"><code>class Print {
  public:
      char name[255];  // name will be overridden from Human class.
      void print() { std::cout &lt;&lt; name &lt;&lt; std::endl; }  // `this.name` should be from Human class.
  };
  
  class Human : public Print {
  public:
      char name[255];
  };
  
  int main() {
      Human h;
      h.name = &quot;Somename&quot;;
      h.print(); // Should outputs: Somename
  }
  </code></pre>