title: Does Overloading Operator<< works inside the class?
body: <p>I mean, I was trying to overload the operator&lt;&lt; inside the class</p>
  
  <p>like this</p>
  
  <pre><code> class A {
        public:
             ostream &amp;operator&lt;&lt;(ostream &amp;os);// which doesnt work
  
        private:
             friend ostream &amp;operator&lt;&lt;(ostream &amp;os, const A&amp; a); //Works
             int i;
  
   };
  
    Definition
            ostream &amp;operator&lt;&lt;(ostream &amp;os, const A&amp; a) {
                os&lt;&lt;a.i;
                return os;
            }
  </code></pre>
  
  <p>why can't I overload the operator inside the class specific to class? or Am I missing something? or Am I stupid to even think in such a way? Please advise.</p>