title: inserting unique elements from std::vector to std::set
body: <p>I have a class called <code>Point</code>, used to store x and y double values. I have a <code>std::vector</code> of <code>Point</code>s that contain duplicate values. I am trying to count the number of unique items in this vector.</p>
  
  <p>I thought since <code>std::set</code> only unique objects, creating a <code>set</code> from <code>vector</code> would give me unique values. But I am not getting the right results. I have overloaded the equality operator. But still the duplicate values gets inserted into the <code>set</code>.</p>
  
  <p>the current results are like below..</p>
  
  <pre><code>10,10 repetitions - 1
  10,10 repetitions - 1
  20,20 repetitions - 1
  20,20 repetitions - 1
  </code></pre>
  
  <p>I am expecting...</p>
  
  <pre><code>10,10 repetitions - 2
  20,20 repetitions - 2
  </code></pre>
  
  <p>Any clues where I am wrong? Complete code is below.</p>
  
  <p><strong>Point.h file</strong></p>
  
  <pre><code>#ifndef POINT_H
  #define POINT_H
  class Point
  {
  public:
      Point(double x, double y);
      double getX();
      double getY();
  
      Point(const Point &amp;other);
  
      bool operator == (const Point&amp; p );
      bool operator != (const Point&amp; p );
  
  private:
      double _x;
      double _y;
  };
  #endif // POINT_H
  </code></pre>
  
  <p><strong>Point.cpp file</strong></p>
  
  <pre><code>#include "point.h"
  
  Point::Point(double x, double y)
  {
      _x = x;
      _y = y;
  }
  
  Point::Point(const Point &amp;other)
  {
      _x = other._x;
      _y = other._y;
  }
  
  double Point::getX()
  {
      return _x;
  }
  
  double Point::getY()
  {
      return _y;
  }
  
  bool Point::operator == ( const Point&amp; p )
  {
      return ( (_x  == p._x ) &amp;&amp; (_y == p._y));
  }
  
  bool Point::operator != ( const Point&amp; p )
  {
      return !((*this) == p );
  }
  </code></pre>
  
  <p><strong>main.cpp file</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;set&gt;
  #include "Point.h"
  using namespace std;
  
  int main()
  {
      std::vector &lt;Point*&gt; pointsVector;
      pointsVector.push_back(new Point(10,10));
      pointsVector.push_back(new Point(10,10));
      pointsVector.push_back(new Point(20,20));
      pointsVector.push_back(new Point(20,20));
  
  
      std::set&lt;Point*&gt; uniqueSet( pointsVector.begin(), pointsVector.end() );
  
      std::set&lt;Point*&gt;::iterator it;
      for (it = uniqueSet.begin(); it != uniqueSet.end(); ++it)
      {
          Point* f = *it; // Note the "*" here
          int result = std::count( pointsVector.begin(), pointsVector.end(), f );
          cout &lt;&lt; f-&gt;getX() &lt;&lt; "," &lt;&lt; f-&gt;getY() &lt;&lt; " repetitions - " &lt;&lt; result &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>