title: How to call a operator overloaded function from other functions / methods in c++?
body: <p>I have another class object in my class. Ex:</p>
  
  <p><strong>ParkingMeter.h</strong></p>
  
  <pre><code>class ParkingMeter
  {
  private:
      ParkedCar pCar;
      int minutesPurchased = 0;
  
  public:   
      friend std::istream&amp; operator &gt;&gt; (std::istream, ParkingMeter&amp;);   
  };
  </code></pre>
  
  <p><strong>ParkedCar.h</strong></p>
  
  <pre><code>class ParkedCar
  {
  private:
      std::string maker;
      std::string model;
      std::string color;
      int licenseNumber = 0;
      int minutesParked = 0;
  
  public:
      friend std::istream&amp; operator &gt;&gt; (std::istream&amp;, ParkedCar&amp;);
      friend std::ostream&amp; operator &lt;&lt; (std::ostream&amp;, ParkedCar&amp;);
  };
  </code></pre>
  
  <p>So, when I enter the data for <strong>ParkingMeter</strong> object with it's respective operator overloaded, I want to call the overloaded function for the <strong>ParkedCar</strong> object aswell.</p>
  
  <p>This is what I've got. The operator overloaded function for the <strong>ParkingMeter</strong>:</p>
  
  <pre><code>std::istream&amp; operator&gt;&gt;(std::istream is, ParkingMeter&amp; obj)
  {
      cout &lt;&lt; "How many minutes to buy? ";
      is &gt;&gt; obj.minutesPurchased;
  
      cout &lt;&lt; "Enter the information about your car:\n";
      is &gt;&gt; obj.pCar;
  
      return is;
  }
  </code></pre>
  
  <p>But in my main file, the following code don't word:</p>
  
  <pre><code>ParkingMeter temp;
  std::cin &gt;&gt; temp;
  </code></pre>
  
  <p>Thank you.</p>
  
  <hr>
  
  <p><strong><em>Solution</em></strong></p>
  
  <p>Thanks to @L. F. for pointing my silly mistake. :D</p>
  
  <p>I've forgotten to use the <strong>&amp;</strong> after <em>std::istream</em> in the arguments for the function:</p>
  
  <pre><code>friend std::istream&amp; operator &gt;&gt; (std::istream, ParkingMeter&amp;);
  </code></pre>
  
  <p>Now its works fine:</p>
  
  <pre><code>friend std::istream&amp; operator &gt;&gt; (std::istream&amp;, ParkingMeter&amp;);
  </code></pre>