title: Making a Point class in c++
body: <p>Right now I am using std::pair to represent a 2d point in c++. However, I am getting annoyed with having to write</p>
  
  <pre><code>typedef std::pair&lt;double, double&gt; Point;
  
  Point difference = Point(p2.first - p1.first,
                           p2.second - p1.second);
  </code></pre>
  
  <p>instead of being able to overload operator+ and operator-.</p>
  
  <p>So, my question is, to make my Point class, should I</p>
  
  <ul>
  <li>Publicly derive from std::pair and add my own member functions? This is nice because all my code can stay the same. I am not going to be doing anything like <code>std::pair&lt;double, double&gt;* p = new Point;</code> so I don't have to worry about things like virtual destructors. </li>
  <li>Roll my own Point class, which is annoying since I am duplicating std::pair's functionality, however I am "doing it the pure way".</li>
  <li>Make template specializations of operator+ and operator- for std::pair, which admittedly I don't remember if they go in source or header files.</li>
  </ul>
  
  <p>I guess it's up for debate, I'd really like to do #1 but I don't know if it's a bad idea since I've heard that inheriting from STL is a no-no.</p>