title: C++ how to sort vector<class *> with operator <
body: <p>i have </p>
  
  <pre><code> class c1{
  
  public:
      int number;
  
      c1()
      {
          number=rand()%10;
      }
  
      bool operator &lt; (c1 *w)
      {
          return number &lt; w-&gt;number;
      }
  
  
  };
  
  vector&lt;c1*&gt; vec = { ... }
  sort(vec.begin(),vec.end()) 
  </code></pre>
  
  <p>why it dosent sort ?</p>
  
  <p>but if we had </p>
  
  <pre><code> bool operator &lt; (c1 w)
      {
          return number &lt; w.number;
      }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>vector&lt;c1&gt; vec = { ... }
  </code></pre>
  
  <p>it would have been sorted !</p>