title: How to overload unary minus operator in C++?
body: <p>I'm implementing vector class and I need to get an opposite of some vector. Is it possible to define this method using operator overloading?</p>
  
  <p>Here's what I mean:</p>
  
  <pre><code>Vector2f vector1 = -vector2;
  </code></pre>
  
  <p>Here's what I want this operator to accomplish:</p>
  
  <pre><code>Vector2f&amp; oppositeVector(const Vector2f &amp;_vector)
  {
   x = -_vector.getX();
   y = -_vector.getY();
  
   return *this;
  }
  </code></pre>
  
  <p>Thanks.</p>