How to overload both unary and binary minus operators in C++?
<p>In C++, how are the operator overloading functions distinguished for the unary and binary minus operators?</p>

<p>I am trying to overload both with the following code:</p>

<pre><code>Vector Vector::operator-(){
  return Vector(-x,-y,-z);
}

Vector Vector::operator-(const Vector&amp; v){
  return this* + (-v);
}
</code></pre>

<p>But this spews a lot of errors:</p>

<pre><code>vector.cpp: In member function ‘Vector Vector::operator-(const Vector&amp;)’:
vector.cpp:88:20: error: passing ‘const Vector’ as ‘this’ argument of ‘Vector Vector::operator-()’ discards qualifiers [-fpermissive]
   return this* + (-v);
                    ^
vector.cpp:88:16: error: no match for ‘operator+’ (operand type is ‘Vector’)
   return this* + (-v);
                ^
vector.cpp:88:16: note: candidates are:
vector.cpp:70:8: note: Vector Vector::operator+(const Vector&amp;)
 Vector Vector::operator+(const Vector&amp; v){
        ^
...
</code></pre>

<p>How do I fix this problem?</p>