title: Inheritance in C++ (Parent and Child class)
body: <p>I have a parent class called Athlete and there is a child class called TennisPlayer. There are two attributes in my parent class which are name and annual salary. There is also a read method which take in user input for both classes. Here is how my parent looks like:</p>
  
  <pre><code>class Athlete
  {
  public:
      Athlete();
      Athlete(string name, float annual_salary);
      virtual void read();
      virtual void display();
      string get_name() const;
      float get_annual_salary();
      void set_name(string name);
      void set_annual_salary(float annual_salary);
  private:
      string name;
      float annual_salary;
  };
  
  class TennisPlayer : public Athlete
  {
  public:
      TennisPlayer();
      TennisPlayer(string name, float annual_salary, int current_world_ranking);
      int get_current_world_ranking();
      void set_current_world_ranking(int current_world_ranking);
      virtual void read();
      virtual void display();
  private:
      int current_world_ranking;
  };
  </code></pre>
  
  <p>The read() method for athlete class works perfectly. But when it comes to tennisPlayer which is the child class, something went wrong, it won't take in the user input, instead it straight away ask me for the input of current world ranking. Here is my .cpp for TennisPlayer class:</p>
  
  <pre><code>void TennisPlayer::read()
  {
      cout &lt;&lt; "Enter name for tennis player: " ;
      getline(cin, get_name());
      cout &lt;&lt; "Enter annual salary for tennis player: ";
          cin &gt;&gt; get_annual_salary();
      cout &lt;&lt; "Enter current world ranking: ";
      cin &gt;&gt; current_world_ranking;
  }
  </code></pre>
  
  <p>Conctructor for tennisPlayer class:</p>
  
  <pre><code>TennisPlayer::TennisPlayer(string name, float annual_salary ,int current_world_ranking)
  : Athlete(name , annual_salary)
  {
      this-&gt;current_world_ranking = current_world_ranking;
  }
  </code></pre>
  
  <p>Also there's a problem when reading the annual salary for tennisPlayer. I am not quite familiar with inheritance in C++. Thanks in advance.</p>