title: Using overloaded input operator with this pointer
body: <p>I couldn't find answer to my question, so here it goes. I created class with overloaded >> operator. Later in code, I've got a method which uses the same code, so I wanted to use overloaded operator with this pointer, but it seems it's not that easy. I wonder what's the problem here and how to solve it in elegant form.</p>
  
  <p>Code:</p>
  
  <pre><code>class Zadanie
  {
      int rozmiar;
      vector&lt;int&gt; dane;
  public:
  
  Zadanie(int _rozmiar = 0)
  {
      rozmiar = _rozmiar;
      dane.reserve(rozmiar);
  }
  
  int getRozmiar()              { return rozmiar; }
  void setRozmiar(int _rozmiar) { rozmiar = _rozmiar;}
  
  friend istream &amp; operator &gt;&gt; (istream &amp; StrmWe, Zadanie &amp; zadanie)
  {
      StrmWe &gt;&gt; zadanie.rozmiar;
      for(int i = 0 ; i &lt; zadanie.rozmiar; i++)
      {
          int tmp;
          StrmWe &gt;&gt; tmp;
          zadanie.dane.push_back(tmp);
      }
  
      return StrmWe;
  }
  
  void WczytajDaneZPliku()
  {
      const char* filepath = "data0.txt";
      ifstream plik(filepath);
      //plik.open(filepath, ios::in);
  
      if(plik.good())
          plik &gt;&gt; this;
  
      plik.close();
  }
  </code></pre>
  
  <p>};</p>
  
  <p>Error: no match for 'operator>>' (operand types are 'std::ifstream {aka std::basic_ifstream}' and 'Zadanie* const')</p>
  
  <p>I'm looking forward for someone, who will reveal this mystery for me.</p>