title: c++ : operator overloading
body: <p>I designed simple struct which is pretty similar to <code>std::pair</code>.</p>
  
  <pre><code>struct pii{
      int first;          
      int second;         
      pii (int _first=-1, int _second=-1)
              : first(_first), second(_second)    {}
  
      //
      pii&amp; operator=(const pii &amp;ref){
          first=ref.first;
          second=ref.second;
          return *this;
      }
      pii operator+(const pii &amp;ref){
          return pii(first+ref.first, second+ref.second);
      }
  
      //
      bool operator&lt;(pii &amp;ref){
          if(first&lt;ref.first &amp;&amp; second&lt;ref.second)
              return true;
          return false;
      }
      bool operator&gt;(pii &amp;ref){
          return ref&gt;(*this);
      }
      bool operator&lt;=(pii &amp;ref){
          return !((*this)&gt;ref);
      }
      bool operator&gt;=(pii &amp;ref){
          return !((*this)&lt;ref);
      }
  
      //
      bool operator==(pii &amp;ref){
          if(first==ref.first &amp;&amp; second==ref.second)
              return true;
          return false;
      }
      bool operator!=(pii &amp;ref){
          return !((*this)==ref);
      }
  };
  </code></pre>
  
  <p>Let's assume there are two <code>pii</code> objects. I want to convert the following sentence using compare operations(<code>&lt;</code>, <code>&gt;</code>, <code>&lt;=</code>, <code>&gt;=</code>, <code>==</code>, <code>!=</code>).</p>
  
  <pre><code>pii one, another;
  //   I want to convert the below sentence.
  if(one.first&lt;=another.first &amp;&amp; one.second&lt;=another.second)
  </code></pre>
  
  <blockquote>
    <p><code>if(one&lt;=another)</code>    //  it is not correct answer.</p>
  </blockquote>
  
  <p>Is it possible to convert? then, What is the answer?</p>