title: Why is it possible to place friend function definitions inside of a class definition?
body: <p>Is it not supposed for a friend function to be explicitly defined outside of a class ?<br>
  If so why can i declare a friend function inside a class definition just like any member function ?<br>
  What is this ?<br>
  Is it only OK with some operators such as <code>&lt;</code> operator or is it applicable to all operators?<br>
  If it is applicable to all of them, Is there any disadvantage for doing this ?<br>
  Should it be avoided? If so why ? </p>
  
  <pre><code>class person 
  {
  public:
      bool operator&lt;(int num)
      {
          return  x &lt; num ? true : false ;
      }
      bool operator&lt;(person&amp; p)
      {
          return  x &lt; p.x ? true : false ;
      }
  
      friend bool operator&lt;(int num, person &amp;p)
      {
          return  p.x &lt; num ? true : false ;
      }
  
      void setX(int num)
      {
          x = num;
      }
  
  private:
      int x;
  
  
  };
  </code></pre>
  
  <p><strong>Update</strong>:<br>
  I am not asking for choosing non-member operator overloading or member operator overloading.<br>
  What i want to know is that :<br>
  Why we are permitted to move the <strong>definition of friend methods inside our class definition?</strong>.<br>
  Is it not violating any things? If it is not, Why would we have friends in first place?<br>
  We could simply define overloads as member functions ( I know the limitations of member functions ) But i am saying knowing this, <strong>Why isn't compiler complaining that I haven't defined friend function outside a class definition</strong> since it doesn't need to be inside of it (because of the class parameter it has)
  So why are we allowed to define a friend function inside a class definition?  </p>