Sep 19, 2011 at 3:19pm UTC
I've ran into this today: ( 40 + +2 ) . Does the +2 denote a positive integer just as -2 denotes a negative integer?
Wazzak
Sep 19, 2011 at 3:28pm UTC
It is the Unary Plus Operator: +
I'm not quite sure why you would need it there, but it returns the value of its operand; for an integral type, an int is returned.
See Integral Promotions.
Last edited on Sep 19, 2011 at 3:38pm UTC
Sep 19, 2011 at 4:12pm UTC
Thanks for the reply CodeMonkey. So basically, I could omit the prefixing + and it wouldn't make a difference? Are there any cases which require the prefixed + ?
Wazzak
Sep 19, 2011 at 4:30pm UTC
I've personally never found any use for the unary + operator.
And yeah, you could omit it there and it wouldn't make any difference.
Sep 19, 2011 at 4:46pm UTC
Simple enough. Thanks to you both :)
Wazzak
Sep 19, 2011 at 4:53pm UTC
I suppose you could overload it with something so it does something useful, but that would just make your code less intuitive to read.