title: c++ inheritance: Use parent method in child class
body: <p>I'm new to c++, so I hope this question is not too stupid.</p>
  
  <p>I want to have a method in my parent class which can be inherited and can be used in child classes, so I can always use the same functionality everywhere.</p>
  
  <p>I run into a problem with the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class Unit {
  public:
    string test = "Unit string";
    virtual void getString();
  };
  
  class Human: public Unit {
  public:
    string test = "Human string";
    void getScString();
  };
  
  
  void Unit::getString()
  {
      cout &lt;&lt; "output:" &lt;&lt; test; 
  }
  void Human::getScString()
  {
     cout &lt;&lt; "output:" &lt;&lt; test; 
  }
  
  
  int main()
  {
     Human tom  = Human();
     tom.getString(); // output:Unit string
     tom.getScString(); // output:Human string
  
     return 0;
  }
  </code></pre>
  
  <p>Why doesn't tom.getString() do "output:Human string" ?</p>
  
  <p>Do I really have to implement a method like getScString in every child class?</p>