title: Operator overloading for making a set of elements of type pair<int, int>
body: <p>How do I overload the '&lt;' (less than) operator for pair of ints to insert the elements of this type into set. For example, consider the following program</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;utility&gt;
  #include &lt;set&gt;
  using namespace std;
  
  bool operator&lt;(pair&lt;int, int&gt; a, pair&lt;int, int&gt; b){
    if(a.second &lt; b.second) return true;
    if(a.second == b.second) return a.first &lt; b.first;
    return false;
  }
  
  int main(){
    pair&lt;int, int&gt; a = make_pair(1, 4);
    pair&lt;int, int&gt; b = make_pair(2, 3);
    set&lt;pair&lt;int ,int&gt; &gt; s;
    s.insert(b);
    s.insert(a);
    set&lt;pair&lt;int, int&gt; &gt;::iterator it = s.begin();
    for(; it!=s.end(); it++){
      printf("(%d %d)\n", it-&gt;first, it-&gt;second);
    }
    if(a &lt; b) printf("a &lt; b\n");
    else printf("b &lt; a\n");
  }
  </code></pre>
  
  <p>The output produced by the above code is:</p>
  
  <pre><code>(1 4)
  (2 3)
  b &lt; a
  </code></pre>
  
  <p>I want the elements of the set to be ordered by the second element of the pair structure. How to do this?</p>