Are they operators '+' and '-' to manipulate the signness of their operands?
I now know I meant unary plus and minus operators!
I've never seen this operator before.
Have they been introduced in C++11 or later C++ standards?
Are they operators '+' and '-' to manipulate the signness of their operands?
I now know I meant unary plus and minus operators!
I've never seen this operator before.
Have they been introduced in C++11 or later C++ standards?
Unary +
and -
have existed since the early formulations of C in the 1970s.
Note that +
is not a no-op: it will widen the argument to at least an int
type.
Finally note that -1
is not a literal in C++: it is a compile-time evaluable constant expression consisting of the unary negation of the int
literal 1.
Yes, C++ has signed operators.
int a;
a = -20; //valid
a = a + (-30) //valid
Read about signed and unsigned data types here and unary operators here.