-6

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?

Jumogehn
  • 1,102
  • 3
  • 11
  • 29

2 Answers2

5

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.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
0

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.

Saurabh Shrivastava
  • 1,055
  • 1
  • 12
  • 26