title: Order of elements in set of pointers
body: <p>Why does the following code get compiled even though I have commented the <code>A::operator&lt;</code>. I wonder how the output of the following code is printed in ascending order without the <code>&lt;</code> operator. How can I change the order to descending? (<em>note</em>: this code does not get compiled if I use <code>A</code> instead of <code>A*</code> unless I provide a definition for <code>A::operator&lt;</code>)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;set&gt;
  
  using namespace std;
  
  class A
  {
  public:
      A(int v):x(v){}
      virtual ~A(){}
      int x;
      /*bool operator&lt;(const A &amp;a) const
      {
          return x &gt; a.x;
      }*/
  };
  
  int main()
  {
      set&lt;A*&gt; numbers;
      A* a1 = new A(1);
      A* a2 = new A(2);
      A* a3 = new A(3);
      numbers.insert(a2);
      numbers.insert(a3);
      numbers.insert(a1);
      for(set&lt;A*&gt;::iterator itr = numbers.begin();itr!=numbers.end();itr++)
      {
          cout &lt;&lt; (*itr)-&gt;x &lt;&lt; endl;
      }
      // output: 1 2 3
      return 0;
  }
  </code></pre>