Why this code even compile? What is the meaning of "+ +" operator?
#include <string>
int main()
{
std::string c = "abc";
c = c + + "d";
c = c + + + "d";
c = c + + + + "d";
c = c + + + + + "d";
printf("%s\n", c.c_str());
}
There is no + + operator. There's a + operator (which occurs in both unary and binary forms), and a ++ operator, not used here.
Each of those is a binary + operator followed by one or more unary + operators.
This:
c = c + + "d";
is equivalent to
c = c + (+ "d");
This:
c = c + + + "d";
is equivalent to:
c = c + (+ + "d");
or:
c = c + (+ (+ "d"));
And so forth.
That's just a lot of unary pluses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With