title: how to call a private member function in c++
body: <p>I am writing a c++ program where i need to call a private member function from main function.
  Please look at my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class cricket
  {
  private:
      int target_score;
      int overs_bowled;
      int extra_time;
      int penalty;
  
      void cal_penalty()
      {
          if(extra_time &lt;=10)
              penalty = 1;
  
              else if(extra_time &lt;=20)
               penalty = 2;
  
               else
                      penalty = 5;
      }
  
      public:
          void extradata()
          {
              cout &lt;&lt; "\nEnter Target Score : ";
              cin &gt;&gt;target_score;
  
              cout &lt;&lt;"\nEnter Overs bowled : ";
              cin &gt;&gt; overs_bowled;
  
              cout &lt;&lt; "\nEnter extra time : ";
              cin &gt;&gt; extra_time;
          }
  
          void displaydata()
          {
              cout &lt;&lt; "\nTarget Score : "&lt;&lt; target_score;
              cout &lt;&lt; "\nOvers Bowled: " &lt;&lt; overs_bowled;
              cout &lt;&lt; "\nExtra Time : " &lt;&lt; extra_time;
              cout &lt;&lt; "\nPenalty : " &lt;&lt;penalty;
          }
  };
  
  int main()
  {
   cricket c1;
  c1.extradata();
  c1.displaydata();
  
  return 0;
  }
  </code></pre>
  
  <p>Here i am getting all the output correctly but i am confused how to display the value of penalty after checking the extratime. Please edit my program so that i can get the value of penalty based on the input of extra time</p>