title: Overloading operators in typedef structs (c++)
body: <p>I want to make a typedef struct called <code>pos</code> (from position) that stores coordinates x and y. I am trying to overload some operators for this struct, but it does not compile.</p>
  
  <pre><code>typedef struct {
      int x;
      int y;
  
      inline pos operator=(pos a) {
          x=a.x;
          y=a.y;
          return a;
      }
  
      inline pos operator+(pos a) {
          return {a.x+x,a.y+y};
      }
  
      inline bool operator==(pos a) {
         if (a.x==x &amp;&amp; a.y== y)
            return true;
         else
            return false;
      }
  } pos;
  </code></pre>
  
  <p>I also wanted to know the difference between this:</p>
  
  <pre><code>inline bool operator==(pos a) {
      if(a.x==x &amp;&amp; a.y== y)
         return true;
        else
         return false;
  }
  </code></pre>
  
  <p>And this:</p>
  
  <pre><code>bool operator==(pos a) const {
        if(a.x==x &amp;&amp; a.y== y)
           return true;
        else
           return false;
  }
  </code></pre>