A unary operator is an operator which takes only a single argument. Some examples include &, *, !, or postfix or prefix increment/decrement. A binary operator, on the other hand, takes two arguments, examples include binary plus/minus, ( a+b, two arguments), insertion and extraction operators (cout << a, two arguments), etc.
The difference between binary minus and unary minus is that binary subtracts the right operand from the left operand and returns the result, i.e. 4 - 3, 3 is subtracted from 4 and 1 is returned. Unary minus changes the sign (and possibly the type) of a number:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void test(unsignedshort i)
{
std::cout << "test called with an unsigned int";
}
void test(int i)
{
std::cout << "test called with a signed int";
}
int main()
{
unsignedshort i=56;
test(-i);
return 0;
}
test called with a signed int.
Running example: http://coliru.stacked-crooked.com/a/df1ea66fc33e5664
Hope that helps, please do let us know if you have any further questions.
Here is a link describing the use of tags on this forum: http://www.cplusplus.com/articles/z13hAqkS/
Look under "2.1 output tags, combining the above".
@a k n - He's not trolling, he's posting unrelated questions in different topics, as he is supposed to.